//加工入库结算 添加 详情
<template>
  <!-- 集采汇总编辑页 -->
  <div class="e-form">
    <!-- //详情 添加页面 ↓ -->
    <div>
         <div class="tabs">
      <el-tabs tab-position="left" v-model="tabsName" @tab-click="onChangeTab">
        <!-- 基本信息 -->
        <el-tab-pane
          label="基本信息"
          name="baseInfo"
          :disabled="clickTabFlag"
        ></el-tab-pane>
        <el-tab-pane
          label="结算明细"
          name="planDetail"
          :disabled="clickTabFlag"
        ></el-tab-pane>

        <el-tab-pane
          label="服务费用"
          name="fwfy"
          :disabled="clickTabFlag"
        ></el-tab-pane>

        <el-tab-pane
          label="保证金"
          name="bzj"
          :disabled="clickTabFlag"
        ></el-tab-pane>

        <el-tab-pane
          label="差价列表"
          name="cjlb"
          :disabled="clickTabFlag"
        ></el-tab-pane>

        <el-tab-pane
          label="附件信息"
          name="accessory"
          :disabled="clickTabFlag"
        ></el-tab-pane>

        <el-tab-pane
          label="审核历史"
          name="auditHistory"
          :disabled="clickTabFlag"
        ></el-tab-pane>

        <!-- <el-tab-pane
          label="审核历史"
          name="auditHistory"
          :disabled="clickTabFlag"
        ></el-tab-pane> -->
        <div>
          <!-- 基本信息 -->
          <div id="baseInfoCon" class="con">
            <div class="e-form">
              <div class="tabs">
                <div class="tabs-title" id="baseInfo">基本信息</div>
                <div style="width: 100%" class="form">
                     <el-form ref="rulesBase" :rules="rulesBase" :model="formData" label-width="150px">
                                    <el-row>
                                        <el-col :span="12" v-if="Thewas != 'add'" prop="billNo">
                                            <el-form-item label="结算编号：">
                                                <span>{{formData.billNo}}</span>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="单据机构：" prop="orgName">
                                                <span>{{formData.orgName}}</span>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="是否记加工费：" prop="isIncludingProcessingFee">
                                                <el-radio v-model="formData.isIncludingProcessingFee" :label="1">是 (外部加工)</el-radio>
                                                <el-radio v-model="formData.isIncludingProcessingFee" :label="0">否 (自行加工)</el-radio>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="加工合同：" prop="contractName">
                                                <span>{{formData.contractName}}</span>
                                                <el-button @click="ccht" v-if="formData.contractBillId">查看合同</el-button>
                                                 <!-- <el-input v-model="formData.sourceBillNo" ></el-input> -->
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="加工单位：" prop="processingUnitName">
                                                <!-- 加工单位 processingUnitName 合同 contractNam -->
                                                <el-input :disabled="true" v-model="formData.processingUnitName"></el-input>
                                                <el-button @click="xzjsmx">选择验收</el-button>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="原材料来源：" prop="materialSource">
                                                <span>{{formData.materialSource}}</span>
                                                 <!-- <el-input :disabled="true" v-model="formData.materialSource"></el-input> -->
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="收料类型：" prop="receivingType">
                                                <!-- <span>{{formData.amount}}</span> -->
                                                <el-radio v-model="formData.receivingType" :label="0">普通加工</el-radio>
                                                <el-radio v-model="formData.receivingType" :label="1">砼加工</el-radio>
                                                <!-- <el-input v-model="formData.amount"></el-input> -->
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <!-- 返回id、名字 -->
                                            <el-form-item label="结算日期：" prop="settlementDate">
                                                <el-date-picker v-model="formData.settlementDate" type="date" placeholder="选择日期" :clearable="false">
                                                </el-date-picker>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="加工费(元)：">
                                                <span>{{jiagongfei}}</span>
                                                <!-- <el-input v-model="formData.processCost"></el-input> -->
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="录入人员：" prop="entryPersonnelName">
                                                <!-- <span>{{formData.freight}}</span> -->
                                                <span>{{formData.entryPersonnelName}}</span>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>

                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="税率%：" prop="taxRate">
                                               <el-input v-model="formData.taxRate" type="number" @blur="shuilvgaiian"></el-input>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                             <el-form-item label="税价合计：">
                                                 <span>{{shuijiaheji}}</span>
                                                <!-- <span>{{formData.totalAmount}}</span> -->
                                            <!-- <el-input v-model="formData.totalAmount" type="number"></el-input> -->
                                            </el-form-item>
                                        </el-col>
                                    </el-row>

                                      <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="税额：">
                                                <!-- <span>{{formData.taxAmount}}</span> -->
                                                <span>{{shuie}}</span>

                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="累计结算金额：">
                                                  <!-- <el-input v-model="formData.taxDifference"></el-input> -->
                                                  <span>{{leijijiesuanjine}}</span>
                                                  <!-- <span>{{formData.cumulativeSettlementAmount}}</span> -->
                                            </el-form-item>
                                        </el-col>
                                    </el-row>

                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="发票编号：" prop="invoiceNo">
                                               <el-input v-model="formData.invoiceNo"></el-input>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="税额差额(元)：">
                                                    <span>{{formData.taxDifference}}</span>
                                                  <!-- <el-input v-model="formData.billSource"></el-input> -->
                                            </el-form-item>
                                        </el-col>
                                    </el-row>

                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="服务费用(含税,元)：">

                                                <!-- <el-checkbox v-model="formData.freight"></el-checkbox> -->
                                                <span>{{formData.freight}}</span>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="终期结算：">
                                                <el-checkbox v-model="formData.isFinalSettlement"
                                                ></el-checkbox>
                                                  <!-- <el-input v-model="formData.isFinalSettlement"></el-input> -->
                                            </el-form-item>
                                        </el-col>
                                    </el-row>

                                    <el-row>
                                        <el-col :span="12" >
                                            <el-form-item label="冲预付款金额(元)：" >
                                                <el-checkbox v-model="formData.isOffsetAdvancePayment"
                                                 @change="inputchanger3"
                                                 ></el-checkbox>
                                               <el-input :disabled="!formData.isOffsetAdvancePayment" v-model="formData.offsetAdvancePayment"></el-input>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="传财务共享">
                                                   <!-- <el-checkbox v-model="formData.wu"></el-checkbox> -->
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <!-- v-if="formData.businessType == '1'" -->
                                        <el-col :span="12">
                                            <el-form-item label="币种：">
                                                <span>{{formData.currency}}</span>
                                               <!-- <el-input  v-model="formData.currency"></el-input> -->

                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="状态：">
                                                <span>{{  state.find(x=>x.value == formData.state).label  }}</span>
                                                  <!-- <el-input v-model="formData.currency"></el-input> -->
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <!-- v-if="formData.businessType == '1'" -->
                                        <el-col :span="12" >
                                            <el-form-item label="本位币：" prop="baseCurName">
                                                <span>{{formData.baseCurName}}</span>
                                               <!-- <el-input  v-model="formData.baseCurName"></el-input> -->
                                            </el-form-item>

                                        </el-col>
                                        <!-- <el-col :span="12">
                                            <el-form-item label="结算金额(本位币)：">
                                                <span>{{formData.baseCurAmount}}</span>
                                            </el-form-item>
                                        </el-col> -->
                                    </el-row>

                                      <el-row>
                                        <el-col :span="24">
                                            <el-form-item label="备注：">
                                               <el-input type="textarea" :rows="2" laceholder="请输入内容" v-model="formData.remarks"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>

                                </el-form>
                </div>
              </div>
            </div>
          </div>

          <!-- 结算明细 -->
          <div id="planDetailCon" class="con">
            <div class="tabs-title" id="planDetail">结算明细</div>
             <el-tabs
              :class="'childTab ' + childTabClass"
              tab-position="left"
              v-model="tabsNameChild"
              @tab-click="onChangeTab"
            >
              <el-tab-pane
                label="加工费"
                name="materialDetails"
                :disabled="clickTabFlag"
              ></el-tab-pane>
              <el-tab-pane
                label="成品物资"
                name="technicalParameter"
                :disabled="clickTabFlag"
              ></el-tab-pane>
              <el-tab-pane
                label="原物资"
                name="technicalParameter2"
                :disabled="clickTabFlag"
              ></el-tab-pane>
            <div>
                <!-- //加工费 -->
                <div id="planDetailCon">
                  <div class="tabs-title" id="materialDetails">
                    加工费
                  </div>
                   <div class="e-table">
                    <el-table
                      :header-cell-style="{ textAlign: 'center' }"
                      :cell-style="{ textAlign: 'center' }"
                      :data.sync="jgfdata"
                      border
                      style="width: 100%; "
                      :row-class-name="tableRowClassName"
                      :cell-class-name="cellClsNm"
                      @selection-change="planTableSelect"
                       :tree-props="{
                        children: 'children',
                        hasChildren: 'hasChildren',
                        }"
                        default-expand-all
                            row-key="uuid"
                    >
                      <el-table-column prop="topClassName" label="物资类别" width="150">
                      </el-table-column>
                      <el-table-column prop="materialName" label="物资名称" >
                      </el-table-column>
                      <el-table-column prop="spec" label="规格" width="200">
                      </el-table-column>
                      <el-table-column prop="texture" label="材质" width="200">
                      </el-table-column>
                      <el-table-column prop="unit" label="计量单位" width="100">
                      </el-table-column>
                      <el-table-column prop="warehouseName" label="仓库" width="200">
                      </el-table-column>
                      <el-table-column prop="unsettledQuantity" label="未结算数量" width="100">
                      </el-table-column>
                      <el-table-column  label="结算数量" width="150">
                           <template slot-scope="{ row }">
                                <el-input v-if="row.billId || row.billId == ''" v-model.number="row.quantity" type="number" @change="gaibian(row,'数量')"></el-input>
                            </template>
                      </el-table-column>
                      <el-table-column prop="ysdj" label="验收单价(元)" width="100">
                      </el-table-column>
                      <el-table-column prop="settlementUnit" label="加工单价(元)" width="100">
                           <template slot-scope="{ row }">
                               <span>{{row.price}}</span>
                            </template>
                      </el-table-column>
                       <el-table-column
                        label="加工费(元)"
                        width="150"
                      >
                         <template slot-scope="{ row }">
                                <el-input :key="row.uuid" v-if="row.billId || row.billId == ''" v-model.number="row.amount" type="number"  @change="gaibian(row,'加工费')"></el-input>
                            </template>
                      </el-table-column>
                       <el-table-column
                        label="税额差额(元)"
                        width="150"
                      >
                         <template slot-scope="{ row }">
                                <el-input v-if="row.billId || row.billId == ''"  v-model="row.taxDifference" type="number"></el-input>
                            </template>
                      </el-table-column>
                    </el-table>
                    </div>
                </div>

                <!-- //成品物资 -->
                <div id="planDetailCon">
                  <div class="tabs-title" id="technicalParameter">
                    成品物资
                  </div>
                   <div class="e-table">
                    <el-table
                      :header-cell-style="{ textAlign: 'center' }"
                      :cell-style="{ textAlign: 'center' }"
                      :data.sync="cpwzdata"
                      border
                      style="width: 100%; "
                      :row-class-name="tableRowClassName"
                      :cell-class-name="cellClsNm"
                      @selection-change="planTableSelect"
                       :tree-props="{
                        children: 'children',
                        hasChildren: 'hasChildren',
                        }"
                        default-expand-all
                            row-key="uuid"
                    >
                      <el-table-column prop="topClassName" label="物资类别" width="150">
                      </el-table-column>
                      <el-table-column prop="materialName" label="物资名称" >
                      </el-table-column>
                      <el-table-column prop="spec" label="规格" width="200">
                      </el-table-column>
                      <el-table-column prop="texture" label="材质" width="200">
                      </el-table-column>
                      <el-table-column prop="unit" label="计量单位" width="100">
                      </el-table-column>
                      <el-table-column prop="warehouseName" label="仓库" width="200">
                      </el-table-column>
                      <el-table-column prop="unsettledQuantity" label="未结算数量" width="200">
                        <template v-slot='{row}'>
                            <span v-if="!row.children">{{+(+row.unsettledQuantity - +row.quantity).toFixed(4)}}</span>
                        </template>
                      </el-table-column>
                      <el-table-column  label="结算数量" width="150">
                            <template slot-scope="{ row }">
                                <el-input v-if="row.billId || row.billId == ''"  v-model="row.quantity" type="number" @blur="shuilvgaiian2(row)" ></el-input>
                            </template>
                      </el-table-column>
                      <el-table-column prop="price" label="成品单价(元)" width="100">

                      </el-table-column>
                       <el-table-column
                        prop="amount"
                        label="成品金额(元)"
                        width="150"
                      >
                      </el-table-column>

                      <!-- <el-table-column
                        prop="settledPrice"
                        label="总摊销比例%"
                        width="150"
                      >
                      </el-table-column>
                       <el-table-column  label="摊销时间(月)" width="100">
                           <template slot-scope="{ row }">
                                <el-input v-if="row.billId || row.billId == ''" v-model="row.settledAmount" type="number" ></el-input>
                            </template>
                        </el-table-column> -->

                    </el-table>

                    </div>
                </div>

                <!-- //原物资 -->
                <div id="planDetailCon">
                  <div class="tabs-title" id="technicalParameter2">
                    原物资
                  </div>
                   <div class="e-table">
                    <div class="top">
                      <div class="left">
                        <div>
                          <el-button
                            size="small"
                            style="background: rgb(75, 178, 255); color: #fff"
                            @click="addmx"
                            >选择物资</el-button
                          >
                          <el-button
                            size="small"
                            type="danger"
                            >删除</el-button
                          >
                          <!-- <el-button @click="chakan11">
                              查看
                          </el-button> -->
                        </div>
                      </div>
                    </div>
                    <el-table
                      :header-cell-style="{ textAlign: 'center' }"
                      :cell-style="{ textAlign: 'center' }"
                      :data.sync="ywzdata"
                      border
                      style="width: 100%; "
                      :row-class-name="tableRowClassName"
                      :cell-class-name="cellClsNm"
                      @selection-change="planTableSelect"
                       :tree-props="{
                        children: 'children',
                        hasChildren: 'hasChildren',
                        }"
                        default-expand-all
                            row-key="uuid"
                    >
                      <el-table-column prop="topClassName" label="物资类别" width="150">
                      </el-table-column>
                      <el-table-column prop="materialName" label="物资名称" >
                      </el-table-column>
                      <el-table-column prop="spec" label="规格" width="200">
                      </el-table-column>
                      <el-table-column prop="texture" label="材质" width="200">
                      </el-table-column>
                      <el-table-column prop="unit" label="计量单位" width="100">
                      </el-table-column>
                      <el-table-column prop="warehouseName" label="仓库" width="200">
                      </el-table-column>
                      <el-table-column prop="receivedQuantity" label="领用数量" width="150">
                      </el-table-column>
                      <el-table-column label="冲库存数量" width="100">
                           <template slot-scope="{ row }">
                                <el-input v-if="row.billId || row.billId == ''" v-model="row.offsetInventoryQuantity" @change="gaibian2(row,'冲库存数量')" type="number" ></el-input>
                            </template>
                      </el-table-column>
                       <el-table-column
                        prop="price"
                        label="采购单价(元)"
                        width="150"
                      >
                      </el-table-column>
                       <el-table-column
                        label="金额(元)"
                        width="150"
                      >
                            <template slot-scope="{ row }">
                                <el-input v-if="row.billId || row.billId == ''"  v-model="row.amount" type="number" ></el-input>
                            </template>
                      </el-table-column>
                    </el-table>
                    </div>
                </div>

            </div>

            </el-tabs>
          </div>

          <!-- 服务费用 -->
          <div id="fwfyCon" class="con">
                <div class="tabs-title" id="fwfy">服务费用</div>
                    <div class="e-table" style="min-height: auto">
                         <div
                                class="top"
                            >
                                <div class="left">
                                    <div>
                                        <el-button
                                            size="mini"
                                            class="btn-blue"
                                            @click="serviceFeeAdd"
                                            >新增行</el-button
                                        >
                                        <el-button size="mini">删除</el-button>
                                    </div>
                                </div>
                            </div>
                               <!-- @cell-mouse-enter="cellMouseEnterF"
                                @cell-mouse-leave="cellMouseLeaveF"
                                 :row-class-name="tableRowClassNameF"
                                -->
                            <el-table
                                :data="serviceFeeData"
                                border
                                style="width: 100%"
                                :cell-class-name="cellClsNm"
                                :row-class-name="tableRowClassName"
                                :header-cell-style="{ textAlign: 'center' }"
                                :cell-style="{ textAlign: 'center' }"
                            >
                             <el-table-column
                                    label="操作"
                                    fixed
                                    width="100px"
                                    align="left"
                                >
                                    <template v-slot="{ row, $index }">
                                         <!-- :class="{
                                                'icon-delete-active-color':
                                                    MouseEnterIdF == row.dtlId
                                            }" -->
                                        <i
                                            class="el-icon-delete"
                                            style="
                                                cursor: pointer;
                                                font-size: 20px;
                                                color: red;
                                            "

                                            @click="serviceFeeDelete(row,$index)"
                                        ></i>
                                    </template>
                                </el-table-column>
                                <el-table-column  label="合同编号" width="200">
                                    <template v-slot="{ row, $index }">
                                        {{ row.contractBillNo }}
                                        <i
                                            style="
                                                cursor: pointer;
                                                font-size: 20px;
                                            "
                                            class="el-icon-document-copy"
                                            @click="contractDialog(row, $index)"
                                        ></i>
                                    </template>
                                </el-table-column>
                                <el-table-column label="结算单位" width="200">
                                     <template v-slot="{ row, $index }">
                                        {{ row.settlementUnitName }}
                                        <i
                                            style="
                                                cursor: pointer;
                                                font-size: 20px;
                                            "
                                            class="el-icon-document-copy"
                                            @click="
                                                billingUnitDialog(row, $index)
                                            "
                                        ></i>
                                    </template>
                                </el-table-column>
                                <el-table-column label="发票编号" width="200">
                                    <template v-slot="{ row }">
                                           <!-- v-if="
                                                basicFormData.redBillState !=
                                                '3'
                                            " -->
                                             <!-- @blur="invoiceNoBlur(row)" -->
                                        <el-input
                                            v-model="row.invoiceNo"
                                            v-enterInteger1
                                            placeholder=""
                                        ></el-input>
                                        <!-- <span v-else>{{ row.invoiceNo }}</span> -->
                                    </template>
                                </el-table-column>
                                <el-table-column label="清单名称" width="200">
                                    <template v-slot="{ row }">
                                          <!-- @blur="contractDtlNameBlur(row)" -->
                                        <el-input
                                            v-model="row.contractDtlName"
                                            placeholder=""
                                        ></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column  label="数量" >
                                      <template v-slot="{ row }">
                                           <!-- @blur="quantityBlur(row)" -->
                                        <el-input
                                            v-model="row.quantity"
                                            v-enterFloat2
                                            placeholder=""
                                            @input="danjia(row,'数量')"
                                        ></el-input>

                                    </template>
                                </el-table-column>
                                <el-table-column prop="price" label="单价(元)" ></el-table-column>
                                <el-table-column  label="金额(元)" >
                                    <template v-slot="{ row }">
                                          <!-- @blur="amountBlur(row)" -->
                                        <el-input
                                            @input="danjia(row,'金额')"
                                            v-model="row.amount"
                                            v-enterFloat
                                            placeholder=""
                                        ></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="d" label="税率%" >
                                    <template v-slot="{ row }">
                                         <!-- @blur="taxRateBlur(row)" -->
                                        <el-input
                                            @input="shuieheji(row)"
                                            v-model="row.taxRate"
                                            v-enterFloat
                                            placeholder=""
                                        ></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column  label="税额(元)">
                                    <template v-slot="{ row }">
                                         <!-- @blur="taxAmountBlur(row)" -->
                                         <span>{{row.taxAmount}}</span>
                                        <!-- <el-input
                                            v-model="row.taxAmount"
                                            v-enterFloat
                                            placeholder=""
                                        ></el-input> -->
                                    </template>
                                </el-table-column>
                                <el-table-column prop="totalAmount" label="税额合计(元)" width="200"> </el-table-column>
                            </el-table>
                    </div>
          </div>

          <!-- 保证金 -->
          <div id="bzjCon" class="con">
            <div class="tabs-title" id="bzj">保证金</div>
            <div class="lll">^ 暂扣保证金</div>
            <div class="e-table" style="min-height: auto">
                <div
                                class="top"
                            >
                                <div class="left">
                                    <div>
                                        <el-button
                                            size="mini"
                                            class="btn-blue"
                                            @click="addzkbzj"
                                            >添加</el-button
                                        >
                                        <el-button size="mini">删除</el-button>
                                    </div>
                                </div>
                            </div>
                              <!-- @cell-mouse-enter="cellMouseEnter"
                                @cell-mouse-leave="cellMouseLeave" -->
                            <el-table
                                :data="zkbzjtableData"
                                border
                                style="width: 100%"
                                :cell-class-name="cellClsNm"
                            >
                                <el-table-column prop="returnDepositName" label="名称" > </el-table-column>
                                <el-table-column label="暂扣保证金(元)" width="250">
                                    <template v-slot="{ row }">
                                         <el-input v-model="row.amount" @input="zkbzjchange(row)"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column  label="截止上期末暂扣保证金(元)" width="250">
                                    <template v-slot="{ row }">
                                        {{row.previousTotalAmount}}
                                    </template>
                                </el-table-column>
                                <el-table-column  label="截止本期末暂扣保证金(元)" width="250">
                                    <template v-slot="{ row }">
                                        {{row.currentTotalAmount}}
                                    </template>
                                </el-table-column>
                                <el-table-column label="说明" width="250">
                                    <template v-slot="{ row }">
                                         <el-input v-model="row.remarks"></el-input>
                                    </template>
                                </el-table-column>
                            </el-table>
            </div>
            <div class="lll">^ 返还保证金</div>
                <div class="e-table" style="min-height: auto">
                <div
                                class="top"
                            >
                                <div class="left">
                                    <div>
                                        <el-button
                                            size="mini"
                                            class="btn-blue"
                                            @click="fhbzjAdd"
                                            >新增行</el-button
                                        >
                                        <el-button size="mini">删除</el-button>
                                    </div>
                                </div>
                            </div>
                             <!-- @cell-mouse-enter="cellMouseEnter"
                                @cell-mouse-leave="cellMouseLeave" -->
                            <el-table
                                :data="fhbzjtableData"
                                border
                                style="width: 100%"
                                :cell-class-name="cellClsNm"
                            >
                                <el-table-column prop="a1" label="名称" > </el-table-column>
                                <el-table-column prop="a" label="暂扣保证金(元)" width="250"> </el-table-column>
                                <el-table-column prop="a" label="截止上期末暂扣保证金(元)" width="250"> </el-table-column>
                                <el-table-column prop="a" label="截止本期末暂扣保证金(元)" width="250"> </el-table-column>
                                <el-table-column prop="a" label="说明" width="250"> </el-table-column>
                            </el-table>
            </div>
                            <!-- <ComPagination /> -->
          </div>

          <!-- 差价列表 -->
          <div id="cjlbCon" class="con" >
               <div class="tabs-title" id="cjlb">差价列表</div>
                    <div class="e-table" style="min-height: auto">
                               <!-- @cell-mouse-enter="cellMouseEnterF"
                                @cell-mouse-leave="cellMouseLeaveF"
                                 :row-class-name="tableRowClassNameF"
                                -->
                             <el-table
                      :header-cell-style="{ textAlign: 'center' }"
                      :cell-style="{ textAlign: 'center' }"
                      :data.sync="jgfdata"
                      border
                      style="width: 100%; "
                      :row-class-name="tableRowClassName"
                      :cell-class-name="cellClsNm"
                      @selection-change="planTableSelect"
                       :tree-props="{
                        children: 'children',
                        hasChildren: 'hasChildren',
                        }"
                        default-expand-all
                            row-key="uuid"
                    >
                      <el-table-column prop="topClassName" label="物资类别" width="150">
                      </el-table-column>
                      <el-table-column prop="materialName" label="物资名称" >
                      </el-table-column>
                      <el-table-column prop="spec" label="规格" width="200">
                      </el-table-column>
                      <el-table-column prop="texture" label="材质" width="200">
                      </el-table-column>
                      <el-table-column prop="unit" label="计量单位" width="100">
                      </el-table-column>
                      <el-table-column prop="warehouseName" label="仓库" width="200">
                      </el-table-column>
                      <el-table-column  label="结算数量" width="150">
                           <template slot-scope="{ row }">
                                <el-input v-if="row.billId || row.billId == ''" v-model.number="row.quantity" type="number" @change="gaibian(row,'数量')"></el-input>
                            </template>
                      </el-table-column>
                      <el-table-column prop="ysdj" label="验收单价" width="100">
                      </el-table-column>
                      <el-table-column prop="settlementUnit" label="加工单价(元)" width="100">
                           <template slot-scope="{ row }">
                               <span>{{row.price}}</span>
                            </template>
                      </el-table-column>
                       <el-table-column
                        label="加工费(元)"
                        width="150"
                      >
                         <template slot-scope="{ row }">
                                <el-input :key="row.uuid" v-if="row.billId || row.billId == ''" v-model.number="row.amount" type="number"  @change="gaibian(row,'加工费')"></el-input>
                            </template>
                      </el-table-column>
                       <el-table-column
                        label="税额差额(元)"
                        width="150"
                      >
                         <template slot-scope="{ row }">
                                <el-input v-if="row.billId || row.billId == ''"  v-model="row.taxDifference" type="number"></el-input>
                            </template>
                      </el-table-column>
                    </el-table>
                    </div>
          </div>

          <!-- 附件信息 -->
          <div id="accessoryCon" class="con">
            <div class="tabs-title" id="accessory">附件信息</div>
            <attach-comp
              :relationId="attachId"
              bucketName="turnover"
              :isView= "formData.state == 2?true:false"
            />
          </div>

          <!-- 审核历史 -->
          <div id="auditHistoryCon" class="con">
            <div class="tabs-title" id="auditHistory">审核历史</div>
            <div class="e-table">
                <div class="e-table">
                    <ComAuditHistoryIndex :billType="1022" :tableData="shenheArr" @getAuditHistory="getauditHistory" />
                </div>
            </div>
          </div>

        </div>
      </el-tabs>
    </div>
    <div id="seat" :style="{ height: seatHeight + 'px' }"></div>
        <div class="buttons">
            <div v-if="Thewas != 'add' ">
                <el-button
                v-if="formData.state == 2"
                type="primary"
                style="background: #2e61d7"
                >打印</el-button
                >
                <el-button
                    type="primary"
                    style="background: #2e61d7"
                    v-if="
                    formData.state == 2
                "
                    @click="chonghongdan"
                    >冲红单</el-button
                >
                <!-- <button @click="demi1">demo</button> -->
                <exaButtons :auditState="auditState" @exas="exas"></exaButtons>
                <el-button @click="handleClose">关闭</el-button>
            </div>
            <div v-if="Thewas == 'add'">
                <!-- <span class="tip"><span style="color: red; margin-right: 0">*</span>为必填项</span> -->
                <el-button
                type="primary"
                class="btn-blue"
                @click="submitCommit"
                size="small"
                >保存并提交</el-button
                >
                <el-button
                    type="primary"
                    class="btn-blue"
                    @click="submit"
                    size="small"
                    >保存</el-button
                >
                <!-- <button @click="chakand">查看</button> -->
                <el-button size="small" @click="handleClose">取消</el-button>
            </div>
        </div>

    <!-- <span style="display: none">{{ localPopConfirm }}</span> -->
    </div>
  </div>
</template>

<script>
import '@/utils/jquery.scrollTo.min'
import { mapMutations, mapState } from 'vuex'
import {
    showPromptPop,
    showSuccessPop,
    showLoading,
    hideLoading,
    openAppClient,
    selectDataClient,
    showErrorPop
} from '@/utils/common'

import {   getUuid } from '@/utils/common'
import AttachComp from '@/components/common/attachIndex'
import planRequest from '@/api/turnover/plan.js'
// import { selectDataClient } from '@/utils/common'

import auditRequest from '@/api/materialSettlement/machiningment.js'
import publicRequest from '@/api/materialSettlement/public.js'

// import ComAuditHistoryIndex from '@/components/common/exaHistory.vue'
import ComAuditHistoryIndex from '@/pages/materialsmanagement/components/auditHistory/auditHistoryIndex'

import publicReques from '@/api/materialSettlement/public.js'
// import {  showErrorPop } from '@/utils/common'
import exaButtons from '@/components/common/exaButtons'
// import historyUpdateTable from '@/components/common/historyUpdateTable'

export default {
    components: {
        AttachComp,
        ComAuditHistoryIndex,
        exaButtons
        // historyUpdateTable
    },
    data () {
        return {
            rulesBase: {
                // taxRate processingUnitName
                taxRate: [
                    { required: true, message: '税率不能为空', trigger: 'change' }
                ],
                processingUnitName: [
                    { required: true, message: '加工单位不能为空', trigger: 'change' }
                ],
                billNo: [
                    { required: true, message: '结算编号不能为空', trigger: 'change' }
                ],
                orgName: [
                    { required: true, message: '机构不能为空', trigger: 'change' }
                ],
                settlementDate: [
                    { required: true, message: '结算日期不能为空', trigger: 'change' }
                ],
                invoiceNo: [
                    { required: true, message: '发票编号不能为空', trigger: 'change' }
                ],
                baseCurName: [
                    { required: true, message: '本位币', trigger: 'change' }
                ]

            },
            //我的数据:↓
            cjlbData: [], //差价列表
            cjlbTrue: false, //控制差价列表是否显示
            nullifyParams: {
                // 作废
                billId: this.$route.query.billid,
                billType: '1022',
                nullifyDescription: '',
                nullifyReason: true,
                nullifyCreated: '',
                nullifyCreator: '',
                nullifyCreatorId: ''
            },
            Thewas: '',
            zkbzjtableData: [],
            fhbzjtableData: [],
            wzlbTableData: [],

            //验证
            yanzheng: {
                billNo: [
                    { required: true, message: '结算编号不能为空', trigger: 'change' }
                ],
                orgName: [
                    { required: true, message: '机构不能为空', trigger: 'change' }
                ],
                settlementDate: [
                    { required: true, message: '结算日期不能为空', trigger: 'change' }
                ],
                baseCurName: [
                    { required: true, message: '本位币不能为空', trigger: 'change' }
                ]

            },
            formData: {
                billNo: '', //	结算编号
                orgName: '', //机构name
                orgId: '', //机构id 不显示
                isIncludingProcessingFee: 1, //是否计加工费
                contractName: '', //合同名称
                contractBillId: '', //合同id
                contractBillNo: '', //合同编号
                processingUnitName: '', //加工单位名称
                processingUnitId: '', //加工单位 id
                materialSource: '',	//原材料来源
                receivingType: 0, //收料类型 0 普通 1砼加工
                settlementDate: '', //结算日期
                processCost: 0, //加工费
                entryPersonnelName: '', //录入人员名称
                entryPersonnelId: '', //录入人员 id
                taxRate: 0, //税率
                totalAmount: 0, //税价合计
                taxAmount: 0, //税额
                cumulativeSettlementAmount: 0, //累计结算金额
                invoiceNo: '', //发票编号
                taxDifference: 0, //税额差额
                freight: 0, //运输单位费用(含税,元)
                isFinalSettlement: false, //是否为终期结算 需要转成数字
                offsetAdvancePayment: 0, //冲预付款金额
                currency: '', //币种名称
                currencyId: '', //币种id
                state: '0', //状态
                baseCurName: '', //本位币名称
                baseCurId: '', //本位币id
                baseCurRate: 0, //本位币汇率
                baseCurAmount: 0, //结算金额 本位币
                remarks: '', //备注
            },

            typeArr: [
                { name: '零星采购计划', id: 1 },
                { name: '物资采购合同', id: 2 },
                { name: '调拔单', id: 3 },
            ],
            viewList: true,
            paginationInfo: {
                total: 1,
                pageSize: 10,
                currentPage: 0
            },
            query: {
                beginPlanDate: '',
                endPlanDate: '',
                keyword: '',
                limit: 0,
                orgId: '',
                page: 1,
                settlementUnitId: '',
                states: []
            }, //搜索
            searchKey: '', //右上角搜索关键字
            tableData: [], //表格
            shenheArr: [],
            serviceFeeData: [],
            serviceFeeData2: [],
            serviceFeeRow: {
                amount: 0, //金额元
                billId: '',
                changeType: 1,
                contractBillId: '',
                contractBillNo: '',
                contractDtlId: '',
                contractDtlName: '',
                dtlId: '',
                invoiceNo: '',
                price: 0, //单价元
                quantity: 0, //数量
                settlementUnitId: '',
                settlementUnitName: '',
                taxAmount: 0, //税额元
                taxRate: 0, //税率%
                totalAmount: 0 // 税价合计
            },
            auditState: {},
            jgfdata: [], //加工费数组
            cpwzdata: [], //成品物资数组
            ywzdata: [], //原物资数组
            //我的数据:↑
            // auditParams: {
            //     billId: this.$route.query.billid,
            //     billType: 6087,
            //     freeNextUnitIndex: 0,
            //     freeNextUser: '',
            //     isPass: true,
            //     isShareInAudit: true,
            //     opinion: ''
            // },
            tabsName: 'baseInfo',
            userName: '',
            clickId: 'baseInfo',
            tabsNameChild: '',
            childTabClass: '',
            form: {
                name: '',
                region: '',
                date1: '',
                date2: '',
                delivery: false,
                type: [],
                resource: '',
                desc: '',
            },

            OrgtableData: [], //申报机构数据
            OrgSonTableData: [], //申报机构子列表
            materialsTableData: [], //物资汇总数据
            auditHistoryList: [], //审核历史
            planSelect: [], //申报机构表格明细选择项
            value: '',
            textarea: '',
            screenWidth: 0,
            screenHeight: 0,
            lastConHeight: 0,
            MouseEnterId: 0,
            clickTabFlag: false, // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            //基本信息表单数据
            basicFormData: {
                'amount': null,
                'billId': '',
                'billNo': '',
                'founderId': '',
                'founderName': '',
                'gmtCreate': '',
                'gmtModified': '',
                'nullifyCreated': '',
                'nullifyCreator': '',
                'nullifyCreatorId': '',
                'nullifyDescription': '',
                'nullifyReason': '',
                'operator': '',
                'operatorId': '',
                'orgId': '',
                'orgName': '',
                'remarks': '',
                'sourceBillId': '',
                'sourceBillNo': '',
                'sourceType': null,
                'state': '',
                'summaryDate': '',
                'workId': ''
            },
            objFlag: {
                flag5: false,
            },
            orgId: '', //机构id
            orgName: '', //机构名称
            billId: '',
            isSkip: false, //是否跳转
            show: true, //申报机构子列表
            dtlIds: '', //
            //验证
            rules: {
                summaryDate: [
                    { required: true, message: '请输入汇总日期', trigger: 'blur' },
                ],
                currencyId: [
                    { required: true, message: '请选择币种', trigger: 'chenge' },
                ],
            },
            materialsNameData: [], //机构汇总表
            createHistoryData: [], //明细修改历史列表
            errorMsg: [],
            isErrorMsg: true, //是否提醒错误信息
            //我的字段 ↓
            user: '', //当前用户
            //我的字段 ↑
            // 以下为接手后新增
            auditParams: {
                // 审核
                billId: this.$route.query.billid,
                billType: '1022',
                freeNextUnitIndex: 0,
                freeNextUser: '',
                isPass: true,
                isShareInAudit: true,
                opinion: '',
                orgId: '',
                orgName: '',
                userId: '',
                workId: ''
            },
        }
    },
    async created () {
        let data = JSON.parse(localStorage.getItem('vuex'))
        this.orgId = data.userInfo.orgInfo.orgId
        // this.orgName = data.userInfo.orgInfo.orgName
        // this.userId = localStorage.getItem('userId')
        // this.basicFormData.operator = localStorage.getItem('userName')
        // this.billId = this.$route.query.billid
        // this.initData()
        console.log('xx', this.$route.query)
        this.Thewas = this.$route.query.was || 'see'
        console.log('iii', this.Thewas)
        this.user = JSON.parse(localStorage.getItem('vuex'))
        if(this.Thewas == 'add') {
            //新增的时候

            this.user = JSON.parse(localStorage.getItem('vuex'))
            this.$set(this.formData, 'entryPersonnelName', this.user.userInfo.userName)
            this.$set(this.formData, 'entryPersonnelId', this.user.userInfo.userId)
            this.$set(this.formData, 'orgName', this.user.userInfo.orgInfo.orgName)
            this.$set(this.formData, 'orgId', this.user.userInfo.orgInfo.orgId)

            // this.$set(this.formData, 'acceptancePersonnelName', this.user.userInfo.userName)
            // this.$set(this.formData, 'billSource', 1)
            // this.$set(this.formData, 'billSourcetxt', '新增')
        }else{
            this.billId = this.$route.query.billid
            this.auditState = await publicRequest.getCurrentUnitInfo({
                billId: this.$route.query.billid,
                billType: '1022'
            })

            this.billId = this.$route.query.billid
            const billId = this.billId
            this.formData = await auditRequest.getjgrk({ id: billId })
            // this.setSelectedInfo(this.formData)
            // // 客户端弹窗预览结果
            // // 参数依次为: 打开页面地址、标题、回调函数
            // openAppClient('/showSelectedData', '选择结果', function () {
            //     // alert('关闭后回调')
            // })

            this.formData.isFinalSettlement == 1 ? this.formData.isFinalSettlement = true : this.formData.isFinalSettlement = false

            let wzlbTableData1 = await auditRequest.getjgf({ id: billId })
            for(let i = 0 ; i < wzlbTableData1.length; i++) {
                wzlbTableData1[i].uuid = getUuid()
                if(wzlbTableData1[i].children.length > 0) {
                    for(let j = 0; j < wzlbTableData1[i].children.length; j++) {
                        wzlbTableData1[i].children[j].uuid = getUuid()
                    }
                }
            }
            console.log('bb', wzlbTableData1)
            this.jgfdata = wzlbTableData1

            let wzlbTableData2 = await auditRequest.getcpwz({ id: billId })
            for(let i = 0 ; i < wzlbTableData2.length; i++) {
                wzlbTableData2[i].uuid = getUuid()
                if(wzlbTableData2[i].children.length > 0) {
                    for(let j = 0; j < wzlbTableData2[i].children.length; j++) {
                        wzlbTableData2[i].children[j].uuid = getUuid()
                    }
                }
            }
            this.cpwzdata = wzlbTableData2

            let wzlbTableData3 = await auditRequest.getywz({ id: billId })
            for(let i = 0 ; i < wzlbTableData3.length; i++) {
                wzlbTableData3[i].uuid = getUuid()
                if(wzlbTableData3[i].children.length > 0) {
                    for(let j = 0; j < wzlbTableData3[i].children.length; j++) {
                        wzlbTableData3[i].children[j].uuid = getUuid()
                    }
                }
            }
            this.ywzdata = wzlbTableData3

            //服务费用
            this.serviceFeeData = await auditRequest.getfwfy({ id: billId })
            if(this.serviceFeeData.data === null) {
                console.log('222')
                this.serviceFeeData = []
            }

            this.bzjarr = await auditRequest.getbzj({ id: billId })
            if(this.bzjarr.length > 0) {
                for(let i = 0; i < this.bzjarr.length ; i++) {
                    if(this.bzjarr[i].returnDepositType == 1) {
                        //暂扣保证金
                        this.zkbzjtableData.push(this.bzjarr[i])
                    }else{
                        //返还保证金
                        this.fhbzjtableData.push(this.bzjarr[i])
                    }
                }
            }
            console.log(' xxxx', this.zkbzjtableData)
        }
    },
    methods: {
        ...mapMutations(['setPopConfirm', 'setSelectedInfo', 'setHistoryTableData', 'setAuditParams']),
        //我的方法 ↓
        async onsavexb () {
            //保存
            this.formData.processCost = this.jiagongfei - 0 // 加工费
            this.formData.totalAmount = this.shuijiaheji - 0 //税价合计
            this.formData.taxAmount = this.shuie - 0
            this.formData.cumulativeSettlementAmount = this.leijijiesuanjine - 0
            if(this.formData.isFinalSettlement) {
                this.formData.isFinalSettlement = 1
            }else{
                this.formData.isFinalSettlement = 0
            }
            if(this.formData.isIncludingProcessingFee) {
                this.formData.isIncludingProcessingFee = 1
            }else{
                this.formData.isIncludingProcessingFee = 0
            }
            const data = await auditRequest.addjgrk(this.formData)
            this.clientPop('info', '保存成功!是否进行下一步操作？', ()=>{
                this.$router.push({
                    path: '/machiningment',
                    query: {
                        billid: data,
                        was: 'see',
                        billtype: '1022'
                    }
                })
            },
            null,
            this.handleClose
            )

        },
        async chonghongdan () {
            await auditRequest.chonghongdan({ id: this.billId })
            this.clientPop('suc', '冲红单成功')
            this.$router.replace('/materialProcurementlist')
        },
        async exas (arg) {
            console.log(arg)
            if (arg === 'submit') {
                if(this.cpwzdata.length < 0) {
                    showErrorPop('成品物资没有进行添加,请检查！')
                }
                console.log('1') // 保存所有数据
                await this.submit()
            } else if (arg === 'submitCommit') {
                if(this.cpwzdata.length < 0) {
                    showErrorPop('成品物资没有进行添加,请检查！')
                }
                console.log('2') // 保存并提交
                await this.submitCommit()
            } else if (arg === 'audit') {
                console.log('3') // 审核
                await this.shenhe()
            } else if (arg === 'undoAudit') {
                await this.nullify() // 撤销审核
            } else if (arg === 'nullify') {
                console.log('5') // 作废(
                await this.zuofei()
            } else if (arg === 'deleteData') {
                console.log('6') // 删除
                await this.shanchu1()
            }
        },
        ccht () {
            console.log('查看合同')
            openAppClient(`/contractDefinitionShow?billid=${this.formData.contractBillId}&isview=true`, '查看合同')
        },
        zuofei () {
            // showLoading()
            // hideLoading()
            this.setAuditParams(this.nullifyParams)
            // 客户端弹窗弹出本地页面
            openAppClient('/nullifyDialog', '单据作废原因', () => {
                const auditParams = JSON.parse(localStorage.vuex).auditParams
                // this.setSelectedInfo(auditParams)
                // // 客户端弹窗预览结果
                // // 参数依次为: 打开页面地址、标题、回调函数
                // openAppClient('/showSelectedData', '选择结果', function () {
                //     // alert('关闭后回调')
                // })
                showLoading()
                publicRequest
                    .zuofei(auditParams)
                    .then(() => {
                        this.clientPop('suc', '作废成功', this.handleClose)
                    })
                    .finally(() => {
                        hideLoading()
                    })
            })
        },
        async shanchu1 () {
            // await auditRequest.deletejgrk({ id: this.billId })
            this.clientPop('info', '确认删除这条数据吗？此操作不可逆转!', async ()=>{

                await auditRequest.deletejgrk({ id: this.$route.query.billid })

                this.clientPop('suc', '删除成功')
                this.$router.replace({
                    path: '/machiningmentList'
                })

            })
            // await auditRequest.deletejgrk({ id: this.billId })
            // this.clientPop('suc', '删除成功')
            // this.$router.replace('/machiningmentList')
        },
        shenhe () {
            console.log('审核')
            openAppClient('/exaDialog', '填写审核意见',  ()=> {
                const auditParams = JSON.parse(localStorage.vuex).auditParams
                // 将审核意见赋值给参数传给后端
                publicReques.goaudit({
                    billId: this.billId,
                    billType: '1022',
                    isPass: auditParams.isPass,
                    isShareInAudit: false,
                    opinion: auditParams.opinion

                }).then(() => {
                    this.clientPop('suc', '审核成功')
                    this.$router.replace('/machiningmentList')
                }).catch(()=>{
                    this.clientPop('suc', '审核失败')
                })

            })
        },
        async nullify () {
            console.log('撤回')
            await publicReques.goBack({ billId: this.billId, billType: '1022' })
            this.clientPop('suc', '撤回成功')
            this.$router.replace('/machiningmentList')
        },
        chakan11 () {
            console.log(this.wzlbTableData)
        },
        zkbzjchange (row) {
            row.currentTotalAmount = (row.previousTotalAmount - 0) + (row.amount - 0)
        },
        fhbzjAdd () {
            selectDataClient({
                SelectServiceToken: '/materialsettle/purchaseSettlement/listUnreturnAmountForSelect', // 客户端对应方法名
                IsSingleMode: true, // 是否单选 true 单选 false 多选
                SelectedIDs: [], // 已选中id(注意：是上一次已选中的id，不是要传的参数，如果第一次选，则传[])
                InitParamsStr: '0',    // 接口参数(name为模拟参数)
                Title: '选择返还保证金' // 标题
            }).then(() => {
                // this.setSelectedInfo(val)
                // openAppClient('/showSelectedData', '选择结果', function () {
                // })
            })
        },
        shuilvgaiian () {
            if(this.formData.taxRate > 0) {
                if(this.formData.taxRate < 100) {
                    return
                }else{
                    this.formData.taxRate = 0
                    showErrorPop('税率只能在0-100之间,请检查！')
                }
            }else{
                this.formData.taxRate = 0
                showErrorPop('税率只能是数字或者正数,请检查！')
            }
        },
        shuilvgaiian2 (row) {
            if(row.unsettledQuantity - 0 < row.quantity - 0) {
                // alert(row.unsettledQuantity)
                row.quantity = +row.unsettledQuantity
                showErrorPop('不能超过未结算数量,请检查！')
                return
            }
            if(row.quantity > 0) {
                const str = row.quantity + ''
                if(str.length > 1) {
                    if(str[0] == 0 || str[0] == '0') {
                        row.quantity = 0
                        showErrorPop('不能已0开头,请检查！')
                    }
                }else{
                    return
                }
            }else{
                row.quantity = 0
                showErrorPop('结算数量只能是数字或者正数,请检查！')
            }
        },
        addzkbzj () {
            let data = JSON.parse(localStorage.getItem('vuex'))
            const orgid = data.userInfo.orgInfo.orgId
            selectDataClient({
                SelectServiceToken: '/subcontract/basicSettingsBond/getBond', // 客户端对应方法名
                IsSingleMode: false, // 是否单选 true 单选 false 多选
                SelectedIDs: [], // 已选中id(注意：是上一次已选中的id，不是要传的参数，如果第一次选，则传[])
                InitParamsStr: JSON.stringify({
                    orgId: orgid,
                    contractCategoryName: '物资采购合同'
                }),    // 接口参数(name为模拟参数)
                Title: '选择暂扣保证金' // 标题
            }).then(val => {
                //保存用户选择返回数据到store
                // this.zkbzjtableData = val
                for(let i = 0; i < val.length; i++) {
                    this.zkbzjtableData.push({
                        returnDepositName: val[i].name, //保证金名称
                        returnDepositId: val[i].billId, //保证金id
                        amount: 0, //暂扣保证金
                        previousTotalAmount: 0, //截止上期先固定写0
                        currentTotalAmount: 0, //截止本期
                        remarks: '', //备注
                        returnDepositType: 1 //1代表暂扣 2代表返还
                    })
                }
            })
        },
        async demi1 () {
            let jgfquery = []
            for(let i = 0 ; i < this.cpwzdata.length; i++) {
                for(let j = 0 ; j < this.cpwzdata[i].children.length ; j++) {
                    jgfquery.push(this.cpwzdata[i].children[j].dtlId)
                }
            }
            console.log(jgfquery)
            let jgfjk = await auditRequest.getjgflist({
                billId: this.billId,
                finishedGoodsDtlIds: jgfquery
            })
            console.log(jgfjk)
        },
        gaibian2 (obj, type) {
            console.log('333')
            if(type == '冲库存数量') {
                if(obj.offsetInventoryQuantity > obj.unsettledQuantity ) {
                    obj.offsetInventoryQuantity = obj.unsettledQuantity
                    showErrorPop('冲库存数量不能超过未结算数量')
                    return
                }
                obj.price = (obj.amount / obj.offsetInventoryQuantity).toFixed(2) - 0
            }
        },
        gaibian (obj, type) {
            // settledAmount金额 settledQuantity结算数量 settledPrice单价 taxDifference税额差价
            // quantity结算数量  amount加工费
            console.log(type)
            console.log(obj)
            // obj.price = obj.amount / obj.quantity
            console.log('数量', obj.quantity)
            console.log('加工费', obj.amount)

            if(obj.amount - 0 > -99999999  && obj.quantity - 0 > -9999999) {
                console.log('进入判断')
                // amount 加工费   quantity 结算数量
                obj.price = ((obj.amount - 0) / (obj.quantity - 0)).toFixed(2) - 0
                if(obj.price !== obj.ysdj) {
                    console.log('不一样了！！！！', obj)
                    let item = {}
                    for(let i = 0; i < this.jgfdata.length ; i++) {
                        for(let j = 0 ; j < this.jgfdata[i].children.length ; j++) {
                            if(this.jgfdata[i].children[j].uuid == obj.uuid) {
                                item = this.jgfdata[i]
                            }
                        }
                    }
                    console.log('item222', item)
                    const ishave = this.cjlbData.filter(i=>{
                        return item.uuid == i.uuid
                    })
                    console.log('ishave', ishave)
                    if(ishave.length == 0) {
                        this.cjlbData.push(item)
                    }
                }else{
                    console.log('一样了的时候')

                }

                console.log('eee', this.cpwzdata)
                for(let i = 0 ; i < this.cpwzdata.length ; i++) {
                    console.log('进入1')
                    for(let j = 0 ; j < this.cpwzdata[i].children.length ; j++) {
                        //先暂时用物资类别的名称来判断
                        const row = this.cpwzdata[i].children[j]
                        if(row.materialName == obj.materialName) {
                            const item = this.cpwzdata[i].children[j]
                            console.log(item, 'item')
                            console.log('我1')
                            item.price = ((obj.quantity * obj.price) + item.amount).toFixed(2) - 0
                            item.amount = (item.price / item.quantity).toFixed(2) - 0
                        }
                    }
                }
                // for(let i = 0 ; i < this.jgfdata.length ; i++){
                //     for(let j = 0; j < this.jgfdata[i].children.length ; j++){
                //         for(let k = 0; k < this.cpwzdata.length ; k ++){
                //             for(let l = 0 ; l < this.cpwzdata[k].children ; l ++){
                //                 if()
                //             }
                //         }
                //     }
                // }
                console.log(obj)
            }else{
                if(!obj.amount == Number) {
                    obj.price = 0
                }else if(!obj.quantity == Number) {
                    obj.price = 0
                }
            }
            // if(type == '数量') {
            //     if(obj.unsettledQuantity < obj.settledQuantity) {
            //         obj.settledQuantity = obj.unsettledQuantity
            //         if(obj.settledAmount && obj.settledQuantity) {
            //             console.log('进入判断')
            //             obj.settledAmount = obj.settledAmount - 0
            //             obj.settledQuantity = obj.settledQuantity - 0
            //             obj.settledPrice = (obj.settledAmount / obj.settledQuantity) - 0
            //         }else{
            //             console.log('2')
            //             obj.settledPrice =  0
            //         }
            //         showErrorPop('结算数量不能超过未结算数量')
            //     }
            // }
            // console.log('1')
            // console.log(obj.amount, '金额')
            // console.log(obj.settlementUnit, '结算数量')
            // console.log( (obj.amount / obj.settlementUnit) - 0, '计算')
            // if(obj.settledAmount && obj.settledQuantity) {
            //     console.log('进入判断')
            //     obj.settledAmount = obj.settledAmount - 0
            //     obj.settledQuantity = obj.settledQuantity - 0
            //     obj.settledPrice = (((obj.settledAmount / obj.settledQuantity) - 0).toFixed(2)) - 0
            //     obj.taxDifference = obj.settledAmount - obj.acceptanceAmount

            //     // 差额  taxDifference 税额差额

            // }else{
            //     console.log('2')
            //     obj.price =  0
            // }
            // console.log(obj)
        },
        addmx () {
            console.log('新增')
        },
        shuieheji (row) {
            if((row.taxRate - 0) > -999999 && row.taxRate != 0 && (row.amount - 0) > -999999  && row.amount != 0) {
                row.taxAmount = (row.amount * ( row.taxRate / 100) ).toFixed(4)
                row.totalAmount = (row.taxAmount - 0) + (row.amount - 0)
            }
        },
        //选择借支人员
        danjia (row, type) {
            console.log(row)
            console.log(type)
            if((row.amount - 0) > -999999 && row.amount != 0 && (row.quantity - 0) > -999999  && row.quantity != 0) {
                row.price = (row.amount / row.quantity).toFixed(4)
                if(row.taxRate == 0) {
                    row.totalAmount =  row.price
                }
            }
            // if(type == '数量') {

            //     if((row.amount - 0) > -999999 && row.amount != 0 && (row.quantity - 0) > -999999  && row.quantity != 0) {
            //         row.price = (row.amount / row.quantity).toFixed(4)
            //     }
            // }else{
            //     if((row.quantity - 0) > -999999  && row.quantity != 0) {
            //         row.price = (row.amount / row.quantity).toFixed(4)
            //     }
            // }
        },
        xzjzry () {
            //  borrowerName: '', //借资人员名称
            //  borrowerId: '', //借资人员id 不显示
            selectDataClient({
                SelectServiceToken: '/hr/user/getUserUnderOrgPage', // 客户端对应方法名
                IsSingleMode: true, // 是否单选 true 单选 false 多选
                SelectedIDs: [], // 已选中id
                Title: '借支人员选择' // 标题
            }).then(val => {
                // this.setSelectedInfo(val)
                // openAppClient('/showSelectedData', '选择结果', function () {
                // })
                if(val.length > 0) {
                    this.formData.borrowerName = val[0].userName
                    this.form.borrowerId = val[0].userId
                }
            })
        },
        //选择冲销对象
        xzcxdx () {
            // 弹窗选择数据
            selectDataClient({
                SelectServiceToken: '/facilityconnect/lease/receive/plan/contract/receive', // 客户端对应方法名
                IsSingleMode: true, // 是否单选 true 单选 false 多选
                SelectedIDs: [], // 已选中id(注意：是上一次已选中的id，不是要传的参数，如果第一次选，则传[])
                InitParamsStr: JSON.stringify({ name: '' }),    // 接口参数(name为模拟参数)
                Title: '选择机构用户' // 标题
            }).then(val => {
                // 保存用户选择返回数据到store
                // this.setSelectedInfo(val)
                // // 客户端弹窗预览结果
                // // 参数依次为: 打开页面地址、标题、回调函数
                // openAppClient('/showSelectedData', '选择结果', function () {
                //     // alert('关闭后回调')
                // })
                if(val.length > 0) {
                    this.formData.reversalObjectNumber = val[0].leaseUnit
                    this.form.reversalObjectId = val[0].leaseUnitId
                }
            })
        },
        chakand () {
            console.log(this.Thewas)
            console.log(this.Thewas != 'add')
        },
        inputchanger1 (e) {
            console.log('111', e)
            if(e == 2 || e == 3) {
                this.formData.isPersonalBorrowing = false
                this.formData.personalBorrowing = 0
                this.formData.reversalObjectNumber = ''
                this.formData.reversalObjectId = ''
                this.formData.borrowerName = ''
                this.formData.borrowerId = ''
            }
        },
        inputchanger2 (e) {
            console.log('111', e)
            if(e == false) {
                this.formData.personalBorrowing = 0
                this.formData.reversalObjectNumber = ''
                this.formData.reversalObjectId = ''
                this.formData.borrowerName = ''
                this.formData.borrowerId = ''
            }
        },
        inputchanger3 (e) {
            if(e == false) {
                this.formData.offsetAdvancePayment = 0
            }
        },
        tableRowClassNameF ({ row }) {
            if (row.changeType === -1) {
                return 'warning-row'
            }
            return ''
        },
        invoiceNoBlur (row) {
            if (row.changeType == 1) {
                row.changeType = 1
            } else {
                row.changeType = 2
            }
        },
        contractDtlNameBlur (row) {
            if (row.changeType == 1) {
                row.changeType = 1
            } else {
                row.changeType = 2
            }
        },
        // 数量变化时
        quantityBlur (row) {
            if (row.changeType == 1) {
                row.changeType = 1
            } else {
                row.changeType = 2
            }
            // // 不能超过合同数量
            if (row.quantitys) {
                if (row.quantity > row.quantitys) {
                    row.quantity = row.quantitys
                }
            }
            if (!!row.amount && !!row.quantity) {
                row.price = +row.amount / +row.quantity
            }
        },
        // 金额变化时
        amountBlur (row) {
            if (row.changeType == 1) {
                row.changeType = 1
            } else {
                row.changeType = 2
            }
            if (!!row.amount && !!row.quantity) {
                row.price = +row.amount / +row.quantity
            }
            if (!!row.amount && !!row.taxRate) {
                row.taxAmount = row.amount * row.taxRate
            }
            if (!!row.amount && !!row.taxAmount) {
                row.totalAmount = row.amount + row.taxAmount
            }
            this.basicFormData.freight = this.serviceFeeData.reduce(
                (pre, c) => (pre += +c.amount || 0),
                0
            )
        },
        // 税率变化时
        taxRateBlur (row) {
            if (row.changeType == 1) {
                row.changeType = 1
            } else {
                row.changeType = 2
            }
            if (!!row.amount && !!row.taxRate) {
                row.taxAmount = row.amount * row.taxRate
            }
            if (!!row.amount && !!row.taxAmount) {
                row.totalAmount = row.amount + row.taxAmount
            }
        },
        //税额变化时
        taxAmountBlur (row) {
            if (row.changeType == 1) {
                row.changeType = 1
            } else {
                row.changeType = 2
            }
            if (!!row.amount && !!row.taxAmount) {
                row.totalAmount = +row.amount + +row.taxAmount
            }
        },
        serviceFeeDelete (row, index) {
            // this.fuwufeiyongarr.splice(index, 1)
            row.changeType = -1
            row.amount = 0
            console.log(index)
            console.log(row)
            // this.serviceFeeData.splice(1, index)
            // this.serviceFeeData2.push(row)
        },
        async contractDialog (row, index) {
            let contracted = {
                contractId: row.contractBillId,
                contractType: row.contractBillType || 0
            }
            let res = await auditRequest.getContract(
                { orgid: this.orgId },
                contracted
            )
            let result
            // 如果选择的是合同并且合同下有清单,则需带入合同下的清单
            if (res.list && res.list.length > 0) {
                result = res.list.map(item => {
                    return {
                        amount: null,
                        // billId: this.billid,
                        billId: this.billid || '',
                        changeType: 1,
                        contractBillId: res.contractId,
                        contractBillNo: res.contractNumber,
                        contractDtlId: item.detailedId,
                        contractDtlName: item.name,
                        dtlId: '',
                        invoiceNo: '',
                        price: null,
                        quantity: item.quantity,
                        quantitys: item.quantity, // 这个字段是用于在修改数量时,不能大于合同数量的
                        settlementUnitId: res.secondPartyId,
                        settlementUnitName: res.secondPartyName,
                        taxAmount: null,
                        taxRate: res.taxRate,
                        totalAmount: null
                    }
                })
                let _arr = []
                result.forEach(item => {
                    const shouldPush = this.serviceFeeData.every(
                        it => item.contractDtlId !== it.contractDtlId
                    )
                    if (shouldPush) {
                        _arr.push(item)
                    } else {
                        // 找到了清单ID相同
                        const repeatArr = this.serviceFeeData.filter(
                            i => item.contractDtlId === i.contractDtlId
                        )
                        const noPush = repeatArr.some(
                            _its => _its.changeType !== -1
                        )
                        if (!noPush) {
                            _arr.push(item)
                        }
                    }
                })
                if (_arr.length !== 0) {
                    this.serviceFeeData.splice(index, 1, ..._arr)
                }
            } else {
                // 如果选择的合同没有清单
                result = {
                    amount: null,
                    billId: this.billid,
                    changeType: 1,
                    contractBillId: res.contractId,
                    contractBillNo: res.contractNumber,
                    contractDtlId: '',
                    contractDtlName: '',
                    dtlId: '',
                    invoiceNo: '',
                    price: null,
                    quantity: null,
                    settlementUnitId: res.secondPartyId,
                    settlementUnitName: res.secondPartyName,
                    taxAmount: null,
                    taxRate: res.taxRate,
                    totalAmount: null
                }
                const shouldPush = this.serviceFeeData.every(
                    it => it.contractBillId !== result.contractBillId
                )
                if (shouldPush) {
                    this.serviceFeeData.splice(index, 1, result)
                } else {
                    const repeatArr = this.serviceFeeData.filter(
                        i => i.contractBillId === result.contractBillId
                    )
                    const noPush = repeatArr.some(
                        _its => _its.changeType !== -1
                    )
                    if (!noPush) {
                        this.serviceFeeData.splice(index, 1, result)
                    }
                }
            }
        },
        async billingUnitDialog (row, index) {
            this.jsdwIds = row.settlementUnitId
            let res = await auditRequest.getBillingUnit(this.jsdwData, this.jsdwIds)
            // async getServeList () { // 弹窗好了,需删除这行
            //     let res = await request.getServeList(this.billingUnitQuery) // 弹窗好了,需删除这行
            let result = {
                amount: null,
                billId: this.billid,
                changeType: 1,
                contractBillId: '',
                contractBillNo: '',
                contractDtlId: '',
                contractDtlName: '',
                dtlId: '',
                invoiceNo: '',
                price: null,
                quantity: null,
                settlementUnitId: res.id,
                settlementUnitName: res.outerName,
                taxAmount: null,
                taxRate: null,
                totalAmount: null
            }
            const shouldPush = this.serviceFeeData.every(
                it => it.settlementUnitId !== result.settlementUnitId
            )
            if (shouldPush) {
                this.serviceFeeData.splice(index, 1, result)
            } else {
                const repeatArr = this.serviceFeeData.filter(
                    i => i.settlementUnitId === result.settlementUnitId
                )
                const noPush = repeatArr.some(_its => _its.changeType !== -1)
                if (!noPush) {
                    this.serviceFeeData.splice(index, 1, result)
                }
            }
            this.basicFormData.freight = this.serviceFeeData.reduce(
                (pre, c) => (pre += +c.amount || 0),
                0
            )
        },
        serviceFeeAdd () {
            // this.serviceFeeData.push(this.serviceFeeRow)
            // 弹窗选择数据
            this.serviceFeeData.push( {
                amount: 0, //金额元
                billId: '',
                changeType: 1,
                contractBillId: '',
                contractBillNo: '',
                contractDtlId: '',
                contractDtlName: '',
                dtlId: '',
                invoiceNo: '',
                price: 0, //单价元
                quantity: 0, //数量
                settlementUnitId: '',
                settlementUnitName: '',
                taxAmount: 0, //税额元
                taxRate: 0, //税率%
                totalAmount: 0 // 税价合计
            })
        },
        xzry () {
            selectDataClient({
                SelectServiceToken: '/hr/user/getUserUnderOrgPage', // 客户端对应方法名
                IsSingleMode: true, // 是否单选 true 单选 false 多选
                SelectedIDs: [], // 已选中id
                Title: '人员选择' // 标题
            }).then(val => {
                if(val.length > 0 ) {
                    this.$set(this.formData, 'acceptancePersonnelName', val[0].userName)
                    this.$set(this.formData, 'acceptancePersonnelId', val[0].userId)
                }
            })
        },
        //审核历史
        async getauditHistory () {
            console.log('1111111')
            if(this.billId !== '') {
                console.log('2222')
                const data = await publicReques.getauditHistory({
                    'billId': this.billId,
                    'billType': 1022,
                    'freeNextUnitIndex': 0,
                    'freeNextUser': '',
                    'isPass': true,
                    'isShareInAudit': true,
                    'opinion': ''
                })
                console.log('iop', data)
                // for(let i = 0 ; i < data.length ; i++) {
                //     this.shenheArr.push(data[i])
                // }
                this.shenheArr = [...data]
                console.log('xxx', this.shenheArr)
            }
        },
        async xzjsmx () {
            selectDataClient({
                SelectServiceToken: '/materialsettle/processingAcceptance/listUnsettleFinishedGoodsForSelect', // 客户端对应方法名
                IsSingleMode: true, // 是否单选 true 单选 false 多选
                SelectedIDs: [], // 已选中id(注意：是上一次已选中的id，不是要传的参数，如果第一次选，则传[])
                InitParamsStr: '',    // 接口参数(name为模拟参数)
                Title: '选择结算明细' // 标题
            }).then(async val => {
                console.log(val)
                if(val.length > 0) {
                    this.father1 = {}
                    for(let i = 0 ; i < val.length; i++) {
                        if(val[i].parentId != '0' || val[i].parentId != 0) {
                            this.father1 = val[i]
                        }
                    }
                }
                let res = this.father1 //默认用户选择了第一个 模拟弹窗 processingUnitName

                // this.setSelectedInfo(res)
                // // 客户端弹窗预览结果
                // // 参数依次为: 打开页面地址、标题、回调函数
                // openAppClient('/showSelectedData', '选择结果00', function () {
                //     // alert('关闭后回调')
                // })

                this.$set(this.formData, 'processingUnitName', res.processingUnitName) //加工单位 processingUnitName 合同 contractNam
                this.$set(this.formData, 'processingUnitId', res.processingUnitId)

                this.$set(this.formData, 'contractName', res.contractName) //合同 contractNam
                this.$set(this.formData, 'contractBillId', res.contractId)
                this.$set(this.formData, 'contractBillNo', res.contractNo)

                this.$set(this.formData, 'acceptanceBillId', res.billId) // 验收id
                this.$set(this.formData, 'acceptanceBillNo', res.billNo) // 验收编号
                // baseCurName

                this.$set(this.formData, 'taxRate', res.taxRate)
                // formData.taxRate
                this.$set(this.formData, 'quantity', res.unsettledQuantity )
                // taxRate

                this.$set(this.formData, 'currency', res.currency)
                this.$set(this.formData, 'baseCurName', res.baseCurName)
                //    formData.baseCurName
                if(res.sourceOfRawMaterials == 1) {
                    this.$set(this.formData, 'materialSource', '购买')
                }else{
                    this.$set(this.formData, 'materialSource', '自有')
                }
                // alert('222')

                //成品物资 ↓
                res = []
                for(let i = 0 ; i < val.length ; i++) {
                    if( val[i].parentId != '0' && val[i].parentId != 0) {
                        res.push(val[i])
                    }
                }

                const mapObj1 = {}
                let arr1 = []
                res.forEach(e => {
                    const children = []
                    e.materialClassNameArr = e.materialClassName.split('/')
                    e.materialClassIdArr = e.materialClassId.split('/')
                    let obj
                    const topClassId = e.materialClassIdArr.splice(0, 1).toString()
                    const topClassName = e.materialClassNameArr.splice(0, 1).toString()
                    if (!mapObj1[topClassId]) {
                        obj = {
                            topClassId,
                            topClassName,
                            customId: topClassId,
                            materialClassId: topClassId,
                            materialClassName: topClassName,
                            uuid: getUuid(),
                            totalAmount: null,
                            totalQuantity: null,
                        }
                        //这里需要改成push多个对象   还没改
                        arr1.push(obj)
                        mapObj1[topClassId] = obj
                    } else {
                        obj = mapObj1[topClassId]
                    }
                    children.push({
                    // settledAmount金额 settledQuantity结算数量 settledPrice单价 taxDifference税额差价
                        uuid: getUuid(),
                        billId: this.billId || '',
                        billNo: this.basicFormData.billNo || '',
                        customId: getUuid(),
                        warehouse: e.warehouse,
                        unsettledQuantity: e.unsettledQuantity - 0, //未结算数量
                        acceptedQuantity: null, //已验收数量
                        changeType: 1,
                        dtlId: e.dtlId, //加工收料明细id
                        materialClassId: e.materialClassIdArr.join('/'), //物资类别id(
                        materialClassName: e.materialClassNameArr.join('/'), //物资类别名称
                        materialId: e.materialId, //物资id
                        materialName: e.materialName, //物资名称
                        settledPrice: 0, //单价
                        // quantity: e.surplusQuantity, //数量
                        sourceDtlId: e.dtlId, //源单明细id
                        spec: e.spec, //规格型号
                        texture: e.texture, //材质
                        unit: e.unit, //计量单位
                        warehouseId: e.warehouseId, //仓库id
                        warehouseName: e.warehouseName, //仓库名称
                        settledQuantity: 0, //结算数量
                        settledAmount: 0, //金额
                        acceptanceAmount: e.acceptanceAmount, //验收金额
                        difference: 0, //差额
                        // taxDifference: 0, //税价差额
                        quantity: e.unsettledQuantity, //结算数量 带入未结算数量
                        price: 0,
                        amount: 0,
                        taxDifference: 0, //税价差额
                        iszhoucai: topClassName.indexOf('周材') != -1 ? true : false

                    })
                    obj.children = !obj.children
                        ? children
                        : obj.children.concat(children)
                    // 统计小计
                    const count = obj.children.reduce(
                        (prev, c) => (prev += c.amount || 0),
                        0
                    )
                    obj.materialName = `小计： ${count}`
                    obj.children = this.uniqueArray(obj.children, 'customId')
                })

                this.cpwzdata = JSON.parse(JSON.stringify(arr1))
                console.log('ii', this.cpwzdata)

                // this.setSelectedInfo(this.cpwzdata)
                // // 客户端弹窗预览结果
                // // 参数依次为: 打开页面地址、标题、回调函数
                // openAppClient('/showSelectedData', '选择结果111', function () {
                //     // alert('关闭后回调')
                // })
                // console.log(jgfjk)

                //成品物资 ↑

                //加工费 ↓
                let jgfquery = []
                for(let i = 0 ; i < this.cpwzdata.length; i++) {
                    for(let j = 0 ; j < this.cpwzdata[i].children.length ; j++) {
                        jgfquery.push(this.cpwzdata[i].children[j].dtlId)
                    }
                }
                // jgfdata
                let jgfjk = await auditRequest.getjgflist({
                    billId: val[0].billId,
                    finishedGoodsDtlIds: jgfquery
                })
                // 保存用户选择返回数据到store

                // this.setSelectedInfo(jgfjk)
                // 客户端弹窗预览结果
                // 参数依次为: 打开页面地址、标题、回调函数
                // openAppClient('/showSelectedData', '选择结果222', function () {
                //     // alert('关闭后回调')
                // })
                // console.log(jgfjk)

                res = []
                for(let i = 0 ; i < jgfjk.length ; i++) {
                    if( jgfjk[i].parentId != '0' && jgfjk[i].parentId != 0) {
                        res.push(jgfjk[i])
                    }
                }
                const mapObj = {}
                let arr = []
                res.forEach(e => {
                    const children = []
                    e.materialClassNameArr = e.materialClassName.split('/')
                    e.materialClassIdArr = e.materialClassId.split('/')
                    let obj
                    const topClassId = e.materialClassIdArr.splice(0, 1).toString()
                    const topClassName = e.materialClassNameArr.splice(0, 1).toString()
                    if (!mapObj[topClassId]) {
                        obj = {
                            topClassId,
                            topClassName,
                            customId: topClassId,
                            materialClassId: topClassId,
                            materialClassName: topClassName,
                            uuid: getUuid(),
                            totalAmount: null,
                            totalQuantity: null,
                        }
                        //这里需要改成push多个对象   还没改
                        arr.push(obj)
                        mapObj[topClassId] = obj
                    } else {
                        obj = mapObj[topClassId]
                    }
                    children.push({
                    // settledAmount金额 settledQuantity结算数量 settledPrice单价 taxDifference税额差价
                        uuid: getUuid(),
                        billId: this.billId || '',
                        billNo: this.basicFormData.billNo || '',
                        customId: getUuid(),
                        warehouse: e.warehouse,
                        unsettledQuantity: (e.unsettledQuantity - 0 ) + 2, //未结算数量
                        acceptedQuantity: null, //已验收数量
                        changeType: 1,
                        dtlId: '', //加工收料明细id
                        materialClassId: e.materialClassIdArr.join('/'), //物资类别id(
                        materialClassName: e.materialClassNameArr.join('/'), //物资类别名称
                        materialId: e.listId, //物资id
                        materialName: e.materialName, //物资名称
                        settledPrice: 0, //单价
                        // quantity: e.surplusQuantity, //数量
                        sourceDtlId: '', //源单明细id
                        spec: e.spec, //规格型号
                        texture: e.texture, //材质
                        unit: e.unit, //计量单位 amount
                        warehouseId: e.warehouseId, //仓库id
                        warehouseName: e.warehouseName, //仓库名称
                        settledQuantity: 0, //结算数量
                        settledAmount: 0, //金额
                        acceptanceAmount: e.acceptanceAmount, //验收金额
                        difference: 0, //差额
                        // taxDifference: 0, //税价差额
                        quantity: e.quantity, //结算数量 带入 未结算数量
                        price: 0,
                        amount: 0,
                        ysdj: e.price, //验收单价
                        ysje: e.amount, //验收金额
                        taxDifference: 0 //税价差额
                    })
                    obj.children = !obj.children
                        ? children
                        : obj.children.concat(children)
                    // 统计小计
                    const count = obj.children.reduce(
                        (prev, c) => (prev += c.amount || 0),
                        0
                    )
                    obj.materialName = `小计： ${count}`
                    obj.children = this.uniqueArray(obj.children, 'customId')
                })
                this.jgfdata = JSON.parse(JSON.stringify(arr))

                console.log('eee', this.jgfdata)
                //加工费 ↑

                //原物资 ↓
                let ywzquery = []
                for(let i = 0 ; i < this.cpwzdata.length; i++) {
                    for(let j = 0 ; j < this.cpwzdata[i].children.length ; j++) {
                        ywzquery.push(this.cpwzdata[i].children[j].dtlId)
                    }
                }
                let ywzjk = await auditRequest.getywzlist({
                    billId: this.billId,
                    finishedGoodsDtlIds: ywzquery
                })
                // 保存用户选择返回数据到store

                // this.setSelectedInfo(ywzjk)
                // // 客户端弹窗预览结果
                // // 参数依次为: 打开页面地址、标题、回调函数
                // openAppClient('/showSelectedData', '选择结果11', function () {
                //     // alert('关闭后回调')
                // })

                console.log(jgfjk)
                res = []
                for(let i = 0 ; i < ywzjk.length ; i++) {
                    if( ywzjk[i].parentId != '0' && ywzjk[i].parentId != 0) {
                        res.push(ywzjk[i])
                    }
                }
                const mapObj2 = {}
                let arr2 = []
                res.forEach(e => {
                    const children = []
                    e.materialClassNameArr = e.materialClassName.split('/')
                    e.materialClassIdArr = e.materialClassId.split('/')
                    let obj
                    const topClassId = e.materialClassIdArr.splice(0, 1).toString()
                    const topClassName = e.materialClassNameArr.splice(0, 1).toString()
                    if (!mapObj2[topClassId]) {
                        obj = {
                            topClassId,
                            topClassName,
                            customId: topClassId,
                            materialClassId: topClassId,
                            materialClassName: topClassName,
                            uuid: getUuid(),
                            totalAmount: null,
                            totalQuantity: null,
                        }
                        //这里需要改成push多个对象   还没改
                        arr2.push(obj)
                        mapObj2[topClassId] = obj
                    } else {
                        obj = mapObj2[topClassId]
                    }
                    children.push({
                    // settledAmount金额 settledQuantity结算数量 settledPrice单价 taxDifference税额差价
                        uuid: getUuid(),
                        billId: this.billId || '',
                        billNo: this.basicFormData.billNo || '',
                        customId: getUuid(),
                        warehouse: e.warehouse,
                        unsettledQuantity: (e.unsettledQuantity - 0 ) + 2, //未结算数量
                        acceptedQuantity: null, //已验收数量
                        changeType: 1,
                        dtlId: '', //加工收料明细id
                        materialClassId: e.materialClassIdArr.join('/'), //物资类别id(
                        materialClassName: e.materialClassNameArr.join('/'), //物资类别名称
                        materialId: e.listId, //物资id
                        materialName: e.materialName, //物资名称
                        settledPrice: 0, //单价
                        // quantity: e.surplusQuantity, //数量
                        sourceDtlId: '', //源单明细id
                        spec: e.spec, //规格型号
                        texture: e.texture, //材质
                        unit: e.unit, //计量单位
                        warehouseId: e.warehouseId, //仓库id
                        warehouseName: e.warehouseName, //仓库名称
                        settledQuantity: 0, //结算数量
                        settledAmount: 0, //金额
                        acceptanceAmount: e.acceptanceAmount, //验收金额
                        difference: 0, //差额
                        // taxDifference: 0, //税价差额
                        receivedQuantity: e.receivedQuantity, //领用数量 先写成数字 后面改成字段
                        offsetInventoryQuantity: 0, //冲库存数量 默认0
                        quantity: 0,
                        price: 0, //采购单价
                        amount: 0, //金额
                        taxDifference: 0 //税价差额

                        //  receivedQuantity领用数量 offsetInventoryQuantity冲库存数量
                        //   price 采购单价  amount金额

                    })
                    obj.children = !obj.children
                        ? children
                        : obj.children.concat(children)
                    // 统计小计
                    const count = obj.children.reduce(
                        (prev, c) => (prev += c.amount || 0),
                        0
                    )
                    obj.materialName = `小计： ${count}`
                    obj.children = this.uniqueArray(obj.children, 'customId')
                })
                this.ywzdata = JSON.parse(JSON.stringify(arr2))
                //原物资 ↑

            })
        },
        //明细数据汇总方法
        uniqueArray (arr, key) {
            const map = new Map()
            return arr.filter(item => {
                const val = item[key] + '' || getUuid()
                return !map.has(val) && map.set(val, 1)
            })
        },
        //我的方法 ↑

        initData () {
            this.getCurrentUnitInfo()
            this.getTurnoverCentralizedPurchaseSummaryGetAgencyListByBillId()
            this.getBasicData()
            this.getTurnoverCentralizedPurchaseSummaryGetSummarySetting() //回去物资汇总明细
        },
        //获取按钮状态
        getCurrentUnitInfo () {
            auditRequest.getCurrentUnitInfo(this.auditParams).then(res => {
                this.auditState = res
            })
        },
        //根据周材集采汇总id查询申报机构
        getTurnoverCentralizedPurchaseSummaryGetAgencyListByBillId () {
            planRequest.turnoverCentralizedPurchaseSummaryGetAgencyListByBillId(this.billId).then(res=>{
                this.OrgtableData = res
                // this.rollUp(res)
            })
        },

        //根据周材集采汇总id查询申报机构
        getTurnoverCentralizedPurchaseSummaryGetSummarySetting () {
            planRequest.turnoverCentralizedPurchaseSummaryGetSummarySetting(this.billId).then(res=>{
                console.log(res, '当前打印')
                // this.OrgtableData = res
                this.notSetData = JSON.parse(JSON.stringify(res)) //没去重之前的数据
                //去重
                let children = []
                res.forEach(item=>{
                    item.children.forEach(a=>{
                        children.push(a)
                    })
                })
                var result = []
                var obj = {}
                for (var i = 0; i < children.length; i++) {
                    if ( children[i].materialId in obj) {
                        // 相同时肯定不push
                        if (obj[children[i].materialId] !== children[i].texture) {
                            // 不相同时，判断是否是 '' 和 null，如果是，则表示重复
                            if (!(!obj[children[i].materialId] && !children[i].texture)) {
                                // 当都不是 '' 和 null 时，才表示不重复，此时才push
                                result.push(children[i])
                            }
                        }
                    } else {
                        obj[children[i].materialId] = children[i].texture
                        result.push(children[i])
                    }
                    // obj[children[i].amount] = 1

                }
                res.forEach(item=>{
                    item.uuid = getUuid()

                    item.materialClassName = item.topClassName
                    item.children = result
                    item.children.forEach(v=>{
                        v.uuid = getUuid()
                        v.parentId = item.uuid
                    })
                })
                console.log(result, 'datadata')
                this.materialsTableData = res
            })
        },

        //向上汇总
        rollUp (res) {
            res.forEach(item=>{ //拿到 数据 汇总计划金额
                this.basicFormData.amount += item.totalAmount
            })
        },
        //点击图标的时候 获取历史记录
        clickIcon (dtlId, column) {
            this.setHistoryTableData([])
            alert(dtlId)
            planRequest
                .turnoverAnnualDemandPlanGetHistoryList(
                    dtlId,
                    column,
                    this.auditParams.billType
                )
                .then(res => {
                    this.historyTableData = res
                    this.setHistoryTableData(res)
                })
                .catch(e => {
                    alert(e.message)
                })
        },
        // 编辑的时候造历史修改数据结构
        createHistory (row, e) {
            if (row.dtlId) {
                this.createHistoryData.push({
                    historyId: '',
                    modifedName: '',
                    modifiedDate: '',
                    modifiedId: '',
                    opinion: '',
                    sourceId: row.dtlId,
                    sourceValue: 0,
                    updateColumn: e, //修改字段
                    updatedValue: row[e] //修改后的值
                })
            }
        },
        /**
         * 下边几个按钮
         */
        async thesubimt1 () {
            if(this.Thewas == 'add') {
                this.formData.processCost = this.jiagongfei - 0 // 加工费
                this.formData.totalAmount = this.shuijiaheji - 0 //税价合计
                this.formData.taxAmount = this.shuie - 0
                this.formData.cumulativeSettlementAmount = this.leijijiesuanjine - 0
                if(this.formData.isFinalSettlement) {
                    this.formData.isFinalSettlement = 1
                }else{
                    this.formData.isFinalSettlement = 0
                }
                if(this.formData.isIncludingProcessingFee) {
                    this.formData.isIncludingProcessingFee = 1
                }else{
                    this.formData.isIncludingProcessingFee = 0
                }
                this.billId = await auditRequest.addjgrk(this.formData)
                this.theData = this.billId

            }else{
                if(this.formData.isFinalSettlement) {
                    this.formData.isFinalSettlement = 1
                }else{
                    this.formData.isFinalSettlement = 0
                }
                if(this.formData.isIncludingProcessingFee) {
                    this.formData.isIncludingProcessingFee = 1
                }else{
                    this.formData.isIncludingProcessingFee = 0
                }
                await auditRequest.updatejgrk(this.formData)
                // data = this.billId
                this.theData = this.billId
            }

            //更新加工费 ↓
            if(this.jgfdata.length > 0) {
                for(let i = 0 ; i < this.jgfdata.length ; i++) {
                    if(this.jgfdata[i].children.length > 0) {
                        for(let j = 0; j < this.jgfdata[i].children.length ; j++) {
                            this.jgfdata[i].children[j].billId = this.billId
                            if(this.jgfdata[i].children[j].changeType != -1) {

                                if(this.jgfdata[i].children[j].changeType === null) {

                                    this.jgfdata[i].children[j].changeType = 2
                                }else{

                                    this.jgfdata[i].children[j].changeType = 1
                                }

                                // if(this.Thewas == 'add') {
                                //     this.jgfdata[i].children[j].changeType = 1
                                // }else{
                                //     this.jgfdata[i].children[j].changeType = 2
                                // }
                            }
                        }
                    }
                }
            }
            await auditRequest.updatejgf(this.jgfdata)
            //更新加工费 ↑

            //更新成品物资 ↓
            if(this.cpwzdata.length > 0) {
                for(let i = 0 ; i < this.cpwzdata.length ; i++) {
                    if(this.cpwzdata[i].children.length > 0) {
                        for(let j = 0; j < this.cpwzdata[i].children.length ; j++) {
                            this.cpwzdata[i].children[j].billId = this.billId
                            if(this.cpwzdata[i].children[j].changeType != -1) {
                                if(this.cpwzdata[i].children[j].changeType === null) {

                                    this.cpwzdata[i].children[j].changeType = 2
                                }else{

                                    this.cpwzdata[i].children[j].changeType = 1
                                }
                            }
                        }
                    }
                }
            }
            // this.setSelectedInfo(this.cpwzdata)
            // // // 客户端弹窗预览结果
            // // // 参数依次为: 打开页面地址、标题、回调函数
            // openAppClient('/showSelectedData', '选择结果222', function () {
            //     // alert('关闭后回调')
            // })
            await auditRequest.updatecpwz(this.cpwzdata)
            //更新成品物资 ↑

            //更新原物资 ↓
            if(this.ywzdata.length > 0) {
                for(let i = 0 ; i < this.ywzdata.length ; i++) {
                    if(this.ywzdata[i].children.length > 0) {
                        for(let j = 0; j < this.ywzdata[i].children.length ; j++) {
                            this.ywzdata[i].children[j].billId = this.billId
                            if(this.ywzdata[i].children[j].changeType != -1) {

                                if(this.ywzdata[i].children[j].changeType === null) {

                                    this.ywzdata[i].children[j].changeType = 2
                                }else{

                                    this.ywzdata[i].children[j].changeType = 1
                                }

                                // if(this.Thewas == 'add') {
                                //     this.ywzdata[i].children[j].changeType = 1
                                // }else{
                                //     this.ywzdata[i].children[j].changeType = 2
                                // }
                            }
                        }
                    }
                }
            }
            await auditRequest.updateywz(this.ywzdata)
            //更新原物资 ↑

            //更新服务费用 ↓
            if(this.serviceFeeData.length > 0) {
                for(let i = 0 ;i < this.serviceFeeData.length ; i++) {
                    this.serviceFeeData[i].billId = this.billId
                    if(this.serviceFeeData[i].changeType != -1) {
                        if(this.Thewas == 'add') {
                            this.serviceFeeData[i].changeType = 1
                        }else{
                            this.serviceFeeData[i].changeType = 2
                        }

                    }
                }
            }
            await auditRequest.updatefwfy(this.serviceFeeData)
            //更新服务费用 ↑

            //更新暂扣保证金 ↓
            if(this.zkbzjtableData.length > 0) {
                for(let i = 0 ;i < this.zkbzjtableData.length ; i++) {
                    this.zkbzjtableData[i].billId = this.billId
                    this.zkbzjtableData[i].returnDepositType = 1
                    if(this.zkbzjtableData[i].changeType != -1) {
                        if(this.Thewas == 'add') {
                            this.zkbzjtableData[i].changeType = 1
                        }else{
                            this.zkbzjtableData[i].changeType = 2
                        }

                    }
                }
            }
            await auditRequest.udatebzj(this.zkbzjtableData)
            //更新暂扣保证金 ↑

            //更新返还保证金 ↓
            if(this.fhbzjtableData.length > 0) {
                for(let i = 0 ;i < this.fhbzjtableData.length ; i++) {
                    this.fhbzjtableData[i].billId = this.billId
                    this.fhbzjtableData[i].returnDepositType = 2
                    if(this.fhbzjtableData[i].changeType != -1) {
                        if(this.Thewas == 'add') {
                            this.fhbzjtableData[i].changeType = 1
                        }else{
                            this.fhbzjtableData[i].changeType = 2
                        }
                    }
                }
            }
            await auditRequest.udatebzj(this.fhbzjtableData)
            //更新返回保证金 ↑
            this.clientPop('suc', '保存成功')
            // this.$router.push({ path: '/machiningment', query: { was: 'see', billid: this.formData.billNo, billtype: '1022' } })
            this.$router.replace('/machiningmentList')
        },
        //保存按钮
        async submit () {
            this.$refs.rulesBase.validate(valid => {
                console.log('gg', valid)
                if (valid) {
                    this.thesubimt1()
                } else {
                    console.log('error submit!!')
                    return false
                }
            })

        },

        // 保存并提交
        async submitCommit () {
            this.$refs.rulesBase.validate(valid => {
                console.log('gg', valid)
                if (valid) {
                    this.thetijiao()
                } else {
                    console.log('error submit!!')
                    return false
                }
            })
        },
        async thetijiao () {
            await this.thesubimt1()
            await publicReques.commitexamine(this.auditParams)
            // this.clientPop('suc', '提交成功')
            this.$router.replace('/machiningmentList')
        },
        //计划明细非空验证
        verifyTable () {

            this.errorMsg = []
            if(this.OrgtableData.length > 0) {
                this.OrgtableData.forEach((n, index)=>{
                    if(n.dtls) {
                        n.dtls.forEach(v=>{
                            v.children.forEach(item=>{
                                if(item.changeType !== -1) {
                                    if (item.approvalQuantity == '' || item.approvalQuantity == null) {
                                        let str = `请填写第 ${index + 1} 行的核准数量`
                                        this.errorMsg.push(str)
                                    }
                                    if (item.approvalPrice == '' || item.approvalPrice == null) {
                                        let str = `请填写第 ${index + 1} 行的核准单价`
                                        this.errorMsg.push(str)
                                    }

                                }
                            })
                        })
                    }

                })
            }

            if(this.errorMsg.length > 0) {
                this.isErrorMsg = true

            }else{
                this.isErrorMsg = false

            }

        },
        // nullify () {
        //     //作废
        //     this.setAuditParams(this.nullifyParams)
        //     // 客户端弹窗弹出本地页面
        //     openAppClient('/nullifyDialog', '单据作废原因', () => {
        //         const auditParams = JSON.parse(
        //             localStorage.vuex
        //         ).auditParams
        //         auditRequest.nullify(auditParams).then(() => {
        //             this.clientPop('suc', '作废成功')
        //             this.getCurrentUnitInfo()
        //         })
        //     })
        // },
        //把子列表的数据合并到this.OrgtableData的children
        DoMaterialsTableData () {
            this.OrgtableData.forEach(item=>{
                item.changeType = 1
                item.billId = this.billId

            })
        },

        //点击选择 选择申报单位 获取申报机构
        selectUnit () {
            planRequest.turnoverCentralizedPurchaseSummaryGetAgencyListByOrgId(['1505122036192309249'])
                .then(res => {
                    this.OrgtableData = res
                    this.DoMaterialsTableData() //给数据造billid 和 chengetype
                    this.isCollect = true
                })
        },
        //点击申报单位列表点击编号显示对应子列表
        tableDbShow (row, column) {
            row.dtls = []
            if(column.label === '年度需用计划编号') {
                if(row.changeType == 1) {
                    planRequest.turnoverCentralizedPurchaseSummaryGetAllMaterial(row.annualDemandPlanBillId).then(res=>{
                        this.OrgSonTableData = res
                        this.OrgSonTableData.forEach(item=>{
                            item.changeType = 1
                            item.uuid =  getUuid()
                            item.materialClassName = item.topClassName

                            item.children.forEach(v=>{
                                v.changeType = 1
                                v.parentId = item.uuid
                                v.uuid =  getUuid()
                            })
                            row.dtls.push(item)
                        })
                    })
                }else {
                    planRequest.turnoverCentralizedPurchaseSummaryGetMaterial(row.dtlId).then(res=>{
                        this.OrgSonTableData = res
                        this.OrgSonTableData.forEach(item=>{
                            item.uuid =  getUuid()
                            item.materialClassName = item.topClassName
                            row.dtls.push(item)
                            item.children.forEach(v=>{
                                v.changeType = 2
                                v.parentId = item.uuid
                                v.uuid =  getUuid()
                            })
                        })
                    })
                }

            }

        },
        // 点击子表的选择明细
        selectDetails () {
            console.log('选择明细')
        },
        //点击集中采购单位 选择单位

        clickPurchasingUnit (row) {
            selectDataClient()
            // 弹窗选择数据
            selectDataClient({
                SelectServiceToken: '/hr/org/getChildrenOrg', // 客户端对应方法名
                IsSingleMode: true, // 是否单选 true 单选 false 多选
                SelectedIDs: [], // 已选中id
                Title: '选择全集团组织机构数据', // 标题
                InitParamsStr: JSON.stringify({ orgId: this.basicFormData.orgId }), //参数

            }).then(val => {
                const orgData = val[0] //获取客户端返回的数据
                row.purchasingUnitId = orgData.orgId
                row.purchasingUnitName = orgData.orgName
                row.changeType === 1 ? this.count_(row, 1) : this.count_(row, 2) //判断当前的状态是新增还是修改
                // 保存用户选择返回数据到store
                this.setSelectedInfo(val)
                // 客户端弹窗预览结果
                // 参数依次为: 打开页面地址、标题、回调函数
                // openAppClient('/showSelectedData', '选择结果', function () {
                //     alert('关闭后回调')

                // })
            })
        },
        //点击物资汇总的物资名称，汇总物资下的所有机构
        showA (row) {
            console.log(row, 'row')
            console.log(this.notSetData, 'this.notSetData')
            this.materialsNameData = []
            this.notSetData.forEach(item=>{
                item.children.forEach(b=>{
                    if( row.materialId === b.materialId) {
                        // const obj = {
                        //     orgName: item.orgName,
                        //     materialName: b.materialName,
                        //     spec: b.spec,
                        //     unit: b.unit,
                        //     texture: b.texture,
                        //     planQuantity: b.planQuantity,
                        //     marketPrice: '',
                        //     amount: b.amount
                        // }
                        // this.materialsNameData = []
                        this.materialsNameData.push(b)
                    }
                })
            })

        },
        //申报机构汇总-删除 申报机构汇总表格明细
        deleteMaterials () {
            if (this.planSelect.length > 0) {
                this.OrgtableData.forEach(v=>{
                    this.planSelect.forEach(item=>{
                        if(item.dtlId && item.dtlId === v.dtlId) {
                            v.changeType = -1
                        }
                    })

                })
            }
            if (this.planSelect.length > 0) {
                this.planSelect.forEach(item => {
                    if (item.dtlId) {
                        const newArr = []
                        newArr.push(item)
                        newArr.forEach(item => {
                            this.$set(item, 'changeType', -1)
                        })

                        // this.$refs.multipleTable.clearSelection()
                    } else {
                        const localArr = []
                        localArr.push(item)
                        for (
                            let i = this.OrgtableData.length;
                            i > 0;
                            i--
                        ) {
                            for (let j = 0; j < localArr.length; j++) {
                                if (
                                    this.OrgtableData[i - 1] ===
                                    localArr[j]
                                ) {
                                    this.OrgtableData.splice(i - 1, 1)
                                }
                            }
                        }
                        // this.$refs.multipleTable.clearSelection()
                    }
                })
            }
            console.log(this.OrgtableData)

        },

        //监听明细 机构汇总表格 数据input事件 判断用户是否修改  ，计算金额
        countInput (row) {
            row.changeType === 1 ? this.count_(row, 1) : this.count_(row, 2)
            console.log(this.materialsTableData, '物资汇总')
        },
        // 汇总逻辑
        count_ (row, num) {
            row.changeType = num
            this.basicFormData.amount = null

            row.approvalAmount =  row.approvalQuantity * row.approvalPrice
            this.OrgtableData.forEach(item =>{
                console.log(item, '逻辑汇总')
                item.changeType = num
                this.basicFormData.amount += item.totalAmount = row.approvalAmount  //把汇总的金额给父级 方便汇总计算
                if(item.children) {
                    item.children.forEach(i=>{
                        i.changeType = num
                    })
                }
            })
        },
        //申报机构汇总-明细子列表删除按钮
        deleteEle (row) {

            row.changeType = -1
            this.OrgtableData.forEach(item =>{
                item.changeType = 2
                if(item.dtls) {
                    item.dtls.forEach(v=>{
                        if(v.children) {
                            const data =  v.children.find(i=>{
                                return i.dtlId === row.dtlId
                            })
                            data.changeType = -1

                        }
                    })
                }
            })

        },
        //获取集采汇总id获取基本信息
        getBasicData () {
            planRequest.turnoverCentralizedPurchaseSummaryFindById(this.billId)
                .then(res => {
                    this.basicFormData = res
                })
        },
        //删除提示框
        ctDelete () {
            showPromptPop('确定要删除吗？删除的数据可以在【回收站】还原或彻底删除。')
        },
        //根据集采汇总id删除单据
        delData () {
            planRequest.turnoverCentralizedPurchaseSummaryDelete(this.billId)
                .then(res => {
                    if (res.code == 200) {
                        showSuccessPop('删除成功！')
                        this.isSkip = true
                    }
                    this.$router.push('./revolveCollectList')
                })
        },
        handleFullScreen () {
            this.fullscreen = !this.fullscreen
        },
        //查询附件信息
        getAttach () {
            this.objFlag.flag5 = true
        },
        //申报机构删除逻辑
        tableRowClassName ({ row }) {
            if (row.changeType === -1) {
                return 'warning-row'
            }
            return ''
        },
        //获取用户在 汇总明细-申报机构汇总 表格的已选择项
        planTableSelect (selection) {
            this.planSelect = selection
        },
        //取消
        handleClose () {
            // this.dialogVisible = false
            this.$router.replace('/machiningmentList')
        },
        onChangeTab (e) {
            console.log('clickTabFlag: ', this.clickTabFlag)
            $.scrollTo(`#${e.name}`, 500)
            this.clickId = e.name //记录每次点击的id
            // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            this.clickTabFlag = true
            // 动画结束后，恢复状态
            setTimeout(() => {
                this.clickTabFlag = false
            }, 600)
        },
        // 获取最后一个内容区域的高度，计算底部空白
        getLastConHeight () {
            let si = setInterval(() => {
                // 因为dom异步加载，通过轮询找到渲染后的dom，获取高度
                if (document.getElementById('evaluateCon')) {
                    const lastConHeight =
            document.getElementById('evaluateCon').offsetHeight
                    console.log('lastConHeight: ', lastConHeight)
                    this.lastConHeight = lastConHeight
                    console.log('this.lastConHeight', this.lastConHeight)
                    clearInterval(si)
                    si = null
                }
            }, 100)
        },
        cellClsNm ({ column }) {
            if (column.label === '') {
                return 'fixed-left'
            }
        },
    },
    computed: {
        ...mapState({
            options: state => state.contract.ctClassify,
            popConfirm: 'popConfirm',
            popStatus: 'popStatus',
            userInfo: state => state.userInfo,
            currencyForm: state => state.equip.equipData.currencyForm, //币种
            state: state => state.equip.equipData.state, //通用流程状态

        }),
        //my ↓
        leijijiesuanjine () {
            if(this.formData.cumulativeSettlementAmount == 0 ) {
                let num = 0
                for(let i = 0 ; i < this.jgfdata.length ; i++) {
                    for(let j = 0 ; j < this.jgfdata[i].children.length; j++) {
                        num += this.jgfdata[i].children[j].ysje
                    }
                }
                return num
            }else{
                return this.formData.cumulativeSettlementAmount
            }
        },
        jiagongfei () {
            // if(this.formData.processCost == 0) {
            if(this.jgfdata.length > 0 && this.formData.taxRate > 0) {
                let num = 0
                for(let i = 0 ; i < this.jgfdata.length ; i++) {
                    for(let j = 0 ; j < this.jgfdata[i].children.length ; j++) {
                        num += (this.jgfdata[i].children[j].amount - 0 ) || 0
                    }
                }
                return num
            }else{
                return 0
            }
            // }else{
            //     return this.formData.processCost
            // }
        },
        shuijiaheji () {
            // if(this.formData.totalAmount == 0) {
            if(this.jiagongfei > 0) {
                return this.jiagongfei  + this.shuie
            }else{
                return 0
            }
            // }else{
            //     return this.formData.totalAmount
            // }
        },
        shuie () {
            // taxAmount
            // if(this.formData.taxAmount == 0) {
            if(this.jiagongfei > 0 && this.formData.taxRate > 0) {
                return  this.jiagongfei * (this.formData.taxRate / 100) - 0
            }else{
                return 0
            }
            // }else{
            //     return this.formData.taxAmount
            // }
        },
        jiesuanjine () {
            // settledAmount金额 settledQuantity结算数量 settledPrice单价 taxDifference税额差价
            // if(this.formData.amount == 0) {
            if(this.wzlbTableData.length > 0) {
                let num = 0
                for(let i = 0 ; i < this.wzlbTableData.length; i++) {
                    if(this.wzlbTableData[i].children.length > 0) {
                        for(let j = 0 ; j < this.wzlbTableData[i].children.length; j++) {
                            num += (this.wzlbTableData[i].children[j].settledAmount) - 0 || 0
                        }
                    }
                }
                return num
            }else{
                return 0
            }
            // }else{
            //     return this.formData.amount
            // }
        },
        // my ↑
        yunshufuwufeiyong () {
            if(this.freight != 0) {
                if(this.serviceFeeData.length > 0) {
                    let num = 0
                    for(let i = 0 ; i < this.serviceFeeData.length; i++) {
                        num += this.serviceFeeData[i].totalAmount
                    }
                    return num
                }else{
                    return 0
                }
            }else{
                return 0
            }
        },
        // localPopConfirm () {
        //     if (this.popConfirm) {
        //         switch (this.popStatus) {
        //         case 'prompt':
        //             this.delData()
        //             break
        //         case 'success':
        //             if (this.isSkip) this.handleClose()
        //             break
        //         }
        //         this.setPopConfirm(false)
        //     }
        //     return this.popConfirm
        // },
        judgeRoute () {
            if (this.$route.path.includes('Add')) {
                return false
            }
            return true
        },
        // 填补底部空白，以使高度够滚动
        seatHeight () {
            return this.screenHeight - 72 - this.lastConHeight
        },
        attachId () {
            return this.billId
        },
        statusLable () {
            return param => {
                const state = this.$store.state.equip.equipData.state
                const obj = state.find(x => x.value == param)

                if (obj !== undefined) {
                    return obj.label
                }
            }
        },
    },

    mounted () {
    // 获取最后一个内容区域的高度，计算底部空白
        this.getLastConHeight()

        // 保存所有tabName

        const arr = [
            'baseInfo',
            ['planDetail', 'materialDetails', 'technicalParameter', 'technicalParameter2'],
            'fwfy',
            'bzj',
            'cjlb',
            'accessory',
            'auditHistory',
        ]
        let $idsTop = []
        window.addEventListener('scroll', () => {
            // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            //当点击的tab有子tab时做滚动逻辑
            if (this.clickTabFlag && arr.find(x => x === this.clickId)) {
                this.childTabClass = '' //无子tab时清空tab的类名
                return
            }

            if (!$idsTop[$idsTop.length - 1]) {
                $idsTop = arr.map(item => {
                    let itemTop
                    let arr
                    if (item instanceof Array) {
                        const prevHeight = document.getElementById(item[0]).offsetHeight //因这里一个选项有两个表格，需获取前一个表格的高度进行计算
                        arr = item.map((x, i) => {
                            if (i === 0) {
                                return document.getElementById(x).offsetTop
                            } else {
                                return (
                                    document.getElementById(x).offsetTop +
                  prevHeight +
                  document.getElementById(item[0]).offsetTop
                                )
                            }
                        })
                        return arr
                    } else {
                        itemTop = document.getElementById(item).offsetTop
                        return itemTop
                    }
                })
            }
            const scrollTop =
        document.documentElement.scrollTop || document.body.scrollTop
            // 倒序查找
            let curLocal = 0
            let curLocalChild = 1
            for (let len = $idsTop.length, i = len - 1; i >= 0; i--) {
                if ($idsTop[i] instanceof Array) {
                    let item = $idsTop[i]
                    for (let lenth = item.length, j = lenth - 1; j >= 1; j--) {
                        let itemChild = $idsTop[i][j]
                        if (scrollTop + 1 >= itemChild) {
                            curLocalChild = j
                            break
                        }
                    }
                    if (scrollTop + 1 >= item[0]) {
                        curLocal = i
                        break
                    }
                } else {
                    let item = $idsTop[i]
                    if (scrollTop + 1 >= item) {
                        curLocal = i
                        break
                    }
                }
            }
            // 设置对应tabName
            if (arr[curLocal] instanceof Array) {
                this.tabsName = arr[curLocal][0]
                this.tabsNameChild = arr[curLocal][curLocalChild]
            } else {
                this.tabsName = arr[curLocal]
            }
            // //动态改变二级选项卡类名
            // arr.forEach((item, index) => {
            //     if (item instanceof Array) {
            //         let tabNavHeight = document.querySelector('.childTab .el-tabs__nav')
            //             ? document.querySelector('.childTab .el-tabs__nav').offsetHeight
            //             : 0
            //         if (scrollTop + 1 >= $idsTop[index + 1] - tabNavHeight) {
            //             this.childTabClass = 'childTab2'
            //         } else if (scrollTop <= $idsTop[index][1]) {
            //             this.childTabClass = ''
            //         } else {
            //             this.childTabClass = 'childTab1'
            //         }
            //     }
            // })
        })

        this.screenWidth = document.documentElement.clientWidth
        this.screenHeight = document.documentElement.clientHeight
        window.addEventListener('resize', () => {
            this.screenWidth = document.documentElement.clientWidth
            this.screenHeight = document.documentElement.clientHeight
            $idsTop = arr.map(item => {
                let itemTop
                let arr
                if (item instanceof Array) {
                    const prevHeight = document.getElementById(item[0]).offsetHeight //因这里一个选项有两个表格，需获取前一个表格的高度进行计算
                    arr = item.map((x, i) => {
                        if (i === 0) {
                            return document.getElementById(x).offsetTop
                        } else {
                            return (
                                document.getElementById(x).offsetTop +
                prevHeight +
                document.getElementById(item[0]).offsetTop
                            )
                        }
                    })
                    return arr
                } else {
                    itemTop = document.getElementById(item).offsetTop
                    return itemTop
                }
            })
        })
    },
}
</script>

<style lang="scss" scoped>
.lll{
    width: 100%;
    height: 30px;
    line-height: 30px;
    background: #F2F2F2;
    padding-right: 20px;
    padding-left: 20px;
}
.buttons {
  left: 0;
}
.e-form {
  margin-bottom: 80px;
  padding: 0 20px;
  .tabs-title::before {
    content: "";
    height: 22px;
    width: 8px;
    border-radius: 40px;
    background-color: #2e61d7;
    display: block;
    position: absolute;
    left: 20px;
    margin-right: 20px;
  }
}

.e-table {
  background: #fff;
}
::v-deep.el-table .warning-row {
  display: none;
}
// ::v-deep.el-table__body-wrapper::-webkit-scrollbar{
//      width: 6px !important; // 横向滚动条
//     height: 10px !important// 纵向滚动条
// }

::v-deep .el-table__body-wrapper::-webkit-scrollbar {
  width: 6px; // 横向滚动条
  height: 10px; // 纵向滚动条
}
// 滚动条的滑块
::v-deep .el-table__body-wrapper::-webkit-scrollbar-thumb {
  background-color: #ddd;
  border-radius: 5px;
}
::v-deep.el-table .warning-row {
    display: none;
}
.el-tab-pane {
  margin-left: -10px;
}
.childTab {
  ::v-deep .el-tabs__header {
    position: absolute !important;
  }
  ::v-deep .el-tabs__content {
    padding: 0 0 0 20px !important;
  }
}
.childTab1 {
  ::v-deep .el-tabs__header {
    position: absolute !important;
    .el-tabs__nav-scroll {
      position: relative;
      .el-tabs__nav {
        position: fixed;
        top: 0;
        width: 190px;
      }
    }
  }
}
.childTab2 {
  ::v-deep .el-tabs__header {
    position: absolute !important;
    .el-tabs__nav-scroll {
      position: relative;
      .el-tabs__nav {
        position: absolute;
        bottom: 0;
        width: 100%;
      }
    }
  }
}
</style>
